Reputation: 23173
I need to add a set number of pixels to a div
with jQuery.
Is there an easy command for this or will I need to write some code that first finds the width of the element and then adds the set amount?
Upvotes: 2
Views: 11242
Reputation: 97681
You'll need to write the code yourself. However, doing what you want is trivial:
$('#mydiv').width($('#mydiv').width() + 10);
Or another way, which will work for a whole set of elements:
$('.mydiv').width(function(index, value) {
return value + 10;
});
Upvotes: 5