zadubz
zadubz

Reputation: 1301

How can I replace just the css selector with jQuery?

I would like to replace just the height attribute to min-height

this is how I would normally change the value, but not sure how to change the attribute

 $('.mySelector').css('height','650px')

<div class="mySelector" style="cursor: -moz-grab; width: 1266px; height: 650px;">

My apologies should have mentioned this earlier

Upvotes: 0

Views: 139

Answers (2)

David Hellsing
David Hellsing

Reputation: 108520

If you want to remove the height attribute but add the same value to the min-height style attribute, you could do this:

$('.mySelector').css('min-height', function() {
    return this.height;
}).removeAttr('height');

Upvotes: 1

Mark Pieszak - Trilon.io
Mark Pieszak - Trilon.io

Reputation: 67181

If you have your height set in the height attribute, I think you'd have to do something like this:

var selector = $('.mySelector');

// set the min-height to I guess whatever the height you had set was
selector.css('min-height', selector.attr('height'));

// remove that old height attribute
selector.removeAttr('height');

Upvotes: 6

Related Questions