javascript - JQuery - How can I determine if a specific class has been Toggled? -


<div class="tab1"><div>  <div class="tab1 active"></div> 

given code above how can tell using jquery tab1 class has been changed or 'made active'

one solution think there better version of adding id tab1 div , checking if class has 'active' appended on it.

[psuedocode below]

$('#tab1').click(function() {    var myclass = $(this).attr("class");    if(myclass.stringat(6-12) == active){        //    } }); 

you can use hasclass() check whether has class active. note in code tab1 class , not id should be

$('.tab1').click(function() {//note tab1 class in code   if($(this).hasclass('active')){// check if div has class active or not    //do operation   }) }) 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -