How to override css containing '!important' using jquery?

前端 未结 15 654
清歌不尽
清歌不尽 2020-12-29 21:05

I want to apply height for specific div using jquery but not able to override the \'!important\' keyword using jquery.

Here is

相关标签:
15条回答
  • 2020-12-29 21:26
    $('#divL3.myclass').attr('style', 'height:0px !important');
    

    Would something like the above work?

    0 讨论(0)
  • 2020-12-29 21:27

    Have you tried this?

    $('#divL3.myclass').css('height', '0px !important');
    
    0 讨论(0)
  • 2020-12-29 21:32

    Try This :

    $( '.myclass' ).each(function () {
        this.style.setProperty( 'height', '0px', 'important' );
    });
    

    .setProperty () enables you to pass a third argument which represents the priority.

    0 讨论(0)
提交回复
热议问题