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
Post a Comment