How to style readonly attribute with CSS?

后端 未结 9 1680
忘了有多久
忘了有多久 2020-12-12 21:45

I\'m currently using readonly=\"readonly\" to disable fields. I\'m now trying to style the attribute using CSS. I\'ve tried using

input[readonly] {
/*styling         


        
9条回答
  •  感动是毒
    2020-12-12 21:56

    Use the following to work in all browsers:

     var readOnlyAttr = $('.textBoxClass').attr('readonly');
        if (typeof readOnlyAttr !== 'undefined' && readOnlyAttr !== false) {
            $('.textBoxClass').addClass('locked');
        }
    

提交回复
热议问题