Using pseudo-class combination, you can use css instead of js to achieve the purpose, less js
.textarea:empty:before { display: block; content: '请输入'; color: #ababab; font-size: 15px; text-align: left; }<br>//表示:当textarea元素为空时即没有输入时,有“请输入”这句提示语显示 .textarea:focus:before { display: none; }<br>//当textarea元素聚焦时,刚刚用before伪类加的“请输入”就会隐藏<br><br>.textarea:empty:after { content: '请认真填写。'; color: #ababab; font-size: 11px; text-align: left; } .textarea:focus:focus { display: none; } first-child:after .order:empty+.a { display: block; }<br>//order元素为空时,它下面的那个元素a显示
The above is the detailed content of Example code sharing of css pseudo-class combination usage. For more information, please follow other related articles on the PHP Chinese website!