用新类替换该类,而不保持新类与我们从中获取的位置相同
我想用新代码替换该代码。我使用replaceWith来替换该函数。但是它从之前的位置删除了新类。我希望该班级保留在以前的位置,并且需要替换另一个班级。怎么办呢?? 前任: $('.popinner').insertAfter($('.rContentPopUp')); 当我这样做时,“.rContentPopUp”正在替换“popinner”类。但是“.rContentPopUp”已从旧结构中删除(无论它在哪里)。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 jQuery 中,您可以将类名传递给removeClass函数,例如...
$('#element name').removeClass('classToRemove');
这样做只会从元素中删除该类,留下所有现有的类。然后你可以简单地调用addClass来添加你的新类。我相信这就是你想做的事?
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?