开发者

replace the class with new class without keeping the Newclass same where ever we are taking that from

开发者 https://www.devze.com 2023-04-09 11:55 出处:网络
I want to replace the code with new code. I used replaceWith to replace the function.But it removes the new class from where it was before . I want that class to stay in where ever it was before and n

I want to replace the code with new code. I used replaceWith to replace the function.But it removes the new class from where it was before . I want that class to stay in where ever it was before and need to replace the another class. How to do it?? Ex: $('.popinner').insertAfter($('.rContentPopUp')开发者_开发问答); when I do this".rContentPopUp" is replacing the 'popinner' class. BUt ".rContentPopUp" was removed from old structure where ever it was there.


In jQuery you can pass a class name to the removeClass function eg...

$('#element name').removeClass('classToRemove');

doing this will just remove that class from the element leaving all existing classes. Then you can simply call addClass to add in your new class. I believe this is what you want to do?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号