Hello I have this html structure.
<span class="radio" style="background-position: 0px 0px; "></span>
I just want to check the state when the style changes to
<span class="radio" style="background-position: 0px -50px; "></span>
so I guess this code will match:
var isChecked = $('.yleis span.radio[style*="-50"]')?true:false;
console.log(isChecked);
But why is this always return true?
The result of a jQuery selector (
$('div)etc) will always be a jQuery object. To turn this into a boolean of whether any results exist, check the length property. Anything other than 0 is true.You also don’t need the : after radio.
http://jsfiddle.net/sfkkh/