Use CSS to automatically add 'required field' asterisk to form inputs

前端 未结 16 2767
有刺的猬
有刺的猬 2020-11-28 19:10

What is a good way to overcome the unfortunate fact that this code will not work as desired:

16条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 19:30

    Use jQuery and CSS

    jQuery(document).ready(function() {
     jQuery("[required]").after("*");
    });
    .required {
        position: absolute;
        margin-left: -10px;
        color: #FB0000;
        font-size: 15px;
    }
    
    

提交回复
热议问题