使用 JQuery 从字符串/变量中查找和删除元素
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16581771/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Element find and remove from string/variable using JQuery
提问by Muhammad Shahzad
I am storing some HTML in a variable. Now I want to remove some div tags from this variable: editor_data
:
我将一些 HTML 存储在一个变量中。现在我想从这个变量中删除一些 div 标签editor_data
:
function validate_step_3()
{
var editor_data = CKEDITOR.instances.editor1.getData();
var i = $(editor_data);
alert(i);
}
The alert shows:
警报显示:
[object Object]
[对象对象]
I want to remove this div
我想删除这个 div
editor_data.find('#fetch_InCkeditor').remove();
回答by Suraj Jadhav
$(editor_data).find('#fetch_InCkeditor').remove();
will do. :)
$(editor_data).find('#fetch_InCkeditor').remove();
会做。:)
回答by Sushanth --
idon a page is supposed to be unique.
页面上的id应该是唯一的。
So in this case just this should be sufficient $('#fetch_InCkeditor').remove();
所以在这种情况下,这应该就足够了 $('#fetch_InCkeditor').remove();