Sunday, 18 August 2013

jQuery div class changes

jQuery div class changes

#myDiv is a clickable box, if #myDiv is clicked, there is a class .opened
will be added. my jQuery reads
if ($('#myDiv').hasClass('open')){
var myValue = "1";
}else{
var myValue = "2";
}
Apparently, after the page completed loaded, myValue always equals 2, but
after clicking #myDiv, myValue is still 2. what event should I use to
detect whether my elements change? I'd like to support IE7+ as well.
thanks!

No comments:

Post a Comment