user4910881
user4910881

Reputation:

Access property in div in jquery

I want to access the transform in this div <div id="slideShow3" class="slideShow" style="width: 490px; height: 490px; margin-top: 10px; margin-left: 10px; transform: rotate(-10.9956rad);"> , it's there instead of inside css because the value is edited by a template.

I have tried $('#slideShow3').attr('transform'); doesn't work.

Same problem when I try to get the z-index from this li <li style="z-index: 100;"> <img width="100%" alt="Fish" src="/media/cache/95/2d/952d083ec4919a006ad6666680ea322c.jpg" style="transform: rotate(-32.9867rad);"> </li>

Upvotes: 0

Views: 91

Answers (2)

Kriggs
Kriggs

Reputation: 3778

Use jQuery's css instead of attr, it works like attr, but for the properties inside style atribute:

$('#slideShow3').css('transform');

Upvotes: 1

VVV
VVV

Reputation: 7593

You can't use .attr because it's not an attribute.

style is the attribute.

Try accessing the css method to get the style you want. Like this:

$('#slideShow3').css('transform');
$('#slideShow3').css('z-index');

And if you need to set some css you can add a second parameter to the css function like this

$('#slideShow3').css('z-index', 10);

Upvotes: 2

Related Questions