ariel
ariel

Reputation: 3072

Using JQuery, How can I find an element in a page and remove certain inline css?

CODE:

<ul class="ul_list" style="height: 300px;resize:both;">

How do I find that using JQuery in a page and remove resize:both. I can't do it manualy. Please advise.

Upvotes: 1

Views: 132

Answers (4)

Barbara Laird
Barbara Laird

Reputation: 12717

From http://api.jquery.com/css/:

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 element.

$('.ul_list').css('resize','');

And, just because I love fiddles: http://jsfiddle.net/CFCGV/

Upvotes: 3

Zama Mohammed
Zama Mohammed

Reputation: 339

Never use inline styles in your code, CSS have specificity and cascading nature.

move the resize:both to the external css file, and if you want to change any time, use another css class, and add the class using JavaScript.

This video will be helpful for you http://www.youtube.com/watch?v=SLC83iesr60

Upvotes: 0

Meximize
Meximize

Reputation: 70

You won't be able to completely remove the style, but you can set it back to the default using something like:

$(document).ready(function(){
    $('.ul_list').css('resize':'none');
});

Upvotes: 0

Chad
Chad

Reputation: 5408

$('.ul_list').css({'resize':'none'});

Upvotes: 0

Related Questions