Evanss
Evanss

Reputation: 23593

jQuery if div has CSS of left: 1% then do something

Is it possible to add an if statement to jQuery so when you click an element a function only runs if another div has the CSS value of left: 1%?

Later on the CSS may change and I would need it so when you click an element the first function does not to not fire, but for a different one does.

Upvotes: 2

Views: 4063

Answers (2)

Prasanna
Prasanna

Reputation: 11544

Check out this fiddle:

http://jsfiddle.net/sweG7/

Note that there is position:absolute for the element. Without that jquery always returns the value as 'auto'

Upvotes: 0

Prisoner ZERO
Prisoner ZERO

Reputation: 14166

if ($('.className').css('left') == '1%')
    alert('do something');

Upvotes: 6

Related Questions