how to remove only one style property with jquery

后端 未结 2 380
再見小時候
再見小時候 2020-12-01 02:48

I have a div with this property style=\"-moz-user-select:none; position:static !important;\". I need to remove the -moz-user-select Tried with $(se

相关标签:
2条回答
  • 2020-12-01 02:58

    You can also replace "-moz-user-select:none" with "-moz-user-select:inherit". This will inherit the style value from any parent style or from the default style if no parent style was defined.

    0 讨论(0)
  • 2020-12-01 03:03

    The documentation for css() says that setting the style property to the empty string will remove that property if it does not reside in a stylesheet:

    Setting the value of a style property to an empty string — e.g. $('#mydiv').css('color', '') — removes that property from an element if it has already been directly applied, whether in the HTML style attribute, through jQuery's .css() method, or through direct DOM manipulation of the style property. It does not, however, remove a style that has been applied with a CSS rule in a stylesheet or <style> element.

    Since your styles are inline, you can write:

    $(selector).css("-moz-user-select", "");
    
    0 讨论(0)
提交回复
热议问题