jquery find() 和 remove() 脚本标签不起作用
jquery find() and remove() with script tag not working
>我有以下脚本,可以从给定字符串中成功删除标签。但现在的问题是,如果我不尝试删除脚本标签,下面的 fun() 函数会自动删除脚本标签。有人可以试着向我解释一下吗?
<script src="jquery-1.8.3.js"></script>
<script>
function fun(x)
{
alert(x);
var html = $(x.bold());
html.find('p').remove();
return html.html();
//alert(html);
}
</script>
<input type="button" value="click" onclick="alert(fun('<script>hello script</script><p>hello p</p><div>hello div</div>'))">
实际上你会工作,我想问题是你的jQuery
没有正确添加。
<script src="jquery-1.8.3.js"></script> <!-- jQuery Lib is not added properly-->
这是一个JSFiddle,它正在相应地工作。
试试这个:
function fun(x)
{
alert(x);
var html = x.bold();
html=$(html);
html.find('p').remove();
return($(html).html());
}
http://jsfiddle.net/FArbJ/2/
相关文章:
- <选择>标签不起作用
- jQuery在<TR>TR折叠时标签不起作用
- Magento Jquery引导程序和原型冲突?导航标签不起作用
- Chart.js-悬停弹出-添加带值的标签-不起作用
- IOS Cordova/Phonegap 离线视频源标签不起作用
- Symfony - 嵌入表单中的食谱“添加新标签”不起作用
- jquery find() 和 remove() 脚本标签不起作用
- jQuery 按 ID 名称删除 img 标签不起作用
- 清除 DIV 标签不起作用
- jQuery 运行总计和输出标签不起作用
- 为什么我的 iframe 标签不起作用
- 安卓网络浏览器 B 标签不起作用
- 模式窗口上的标签标签不起作用
- 添加<李>jquery中的标签不起作用
- Vaadin标签不起作用
- Jquery click()事件对附加的HTML标签不起作用
- Jquery选择器对添加的标签不起作用
- 跨域Ajax的动态脚本标签不起作用
- jquery append和javascript appendChild对html标签不起作用
- 为什么click()对对象标签不起作用