Add/Removing Class not working in IE

.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前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏