.toggle(
function() {
hiddenElements.show();
$(this).text('Collapse');
$(".accToggler").removeClass().addClass("accToggler2");
},
function() {
hiddenElements.hide();
$(this).text(showCaption);
$(".accToggler2").removeClass().addClass("accToggler");
}
)
Once the original .accToggler button is clicked the toggle function doesn't seem to be working. The classes are not being added/removed to the button.
I changed it to this:
.toggle(
function() {
hiddenElements.show();
$(this).text('Collapse');
$("#accTogg").removeClass("accToggler").addClass("accToggler2");
},
function() {
hiddenElements.hide();
$(this).text(showCaption);
$("#accTogg").removeClass("accToggler2").addClass("accToggler");
}
)
And still nothing.. should definitely be working now right?
$('.v65-productDisplay').append(
$('
' + showCaption + '
')
.toggle(
function() {
hiddenElements.show();
$(this).text('Collapse');
$("#accTogg").removeClass("accToggler").addClass("accToggler2");
},
function() {
hiddenElements.hide();
$(this).text(showCaption);
$("#accTogg").removeClass("accToggler2").addClass("accToggler");
}
)
);
That's the entire code, sorry.
$(this).text('Collapse');
Is replacing the entire div so it doesn't even exist anymore =/ How can I get it to just replace the text inside of the div? you have to specify which class you want to remove with removeClass(). Alternately you could use api.jquery.com/toggleClass
以上就是Add/Removing Class not working in IE的详细内容,更多请关注web前端其它相关文章!