Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove only one style property with jQuery?

Tags:

jquery

css

People also ask

How we can remove CSS in jQuery?

removeClass(). removeAttr('style');

How do I remove a style tag?

If you want to remove a specific style tag, you can add a class (or id) to it and then use remove() to remove that class.

What is removeAttr in jQuery?

The removeAttr() method is an inbuilt method in jQuery which is used to remove one or more attributes from the selected elements. Syntax: $(selector).removeAttr(attribute) Parameters: This function accepts single parameter attribute which is mandatory. It is used to specify one or more attributes to remove.

How do you remove styles in HTML?

Use the removeAttribute() method to remove all styles from an element, e.g. box. removeAttribute('style') . The removeAttribute method will remove the style attribute from the element. Here is the HTML for the examples in this article.


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", "");