如何使用jquery/javascript替换dom标记类型?
编辑:我有一个RadEditor控件,希望构建一个过滤器来替换标签类型,如。。。具有请参见docs.telerik.com/devtools/aspnet ajax/controls/editor/…其中getHtmlContent为我想要返回结果的函数提供传入参数 看看这里的答案,如何使用此引用的功处理包装函数“r”的传入参数“a”,以便由另一个函数返回。例如,我有如何使用jquery/javascript替换dom标记类型?,javascript,jquery,dom,Javascript,Jquery,Dom,编辑:我有一个RadEditor控件,希望构建一个过滤器来替换标签类型,如。。。具有请参见docs.telerik.com/devtools/aspnet ajax/controls/editor/…其中getHtmlContent为我想要返回结果的函数提供传入参数 看看这里的答案,如何使用此引用的功处理包装函数“r”的传入参数“a”,以便由另一个函数返回。例如,我有 function replaceTagType(a, b, c) { var newContent; /* whe
function replaceTagType(a, b, c) {
var newContent;
/* where 'a' is the target content, 'b' is the target tag type (i.e. <b>)
and 'c' is the new tag type (i.e. <u>). What to put here that uses
above referenced work in "how to change an element type using jquery"
to assign the results to newContent ? */
return newContent;
}
函数替换标记类型(a、b、c){
var新内容;
/*其中“a”是目标内容,“b”是目标标签类型(即
“c”是新的标签类型(即)。在这里使用什么
上面提到了“如何使用jquery更改元素类型”中的工作
要将结果分配给newContent*/
返回新内容;
}
因此,如果a=“test”,则结果var newContent=“test”试试这个
text()
函数获取纯文本(不带html标记)
中的文本创建新的
元素html()
函数替换父元素的内容$.parseHTML(a).find(b).each(function(){
var t=$(本);
t、 parent().html($(“”).text(t.text());
});
检查此项
var a = $("div").html();
//console.log(a);
a=a.replace('<u>', '<b>');
a=a.replace('</u>', '</b>');
$("div").html(a);
var a=$(“div”).html();
//控制台日志(a);
a=a.替换(“”,”);
a=a.替换(“”,”);
$(“div”).html(a);
你不能用test替换test吗?解析
a
,在链接的问题中应用解决方案并将元素转换回HTML?我认为传入的参数a是DOM。上下文:我有一个RadEditor控件,希望构建一个过滤器,以替换标签类型,如。请参阅getHtmlContent在何处为我要返回结果的函数提供传入参数。@FelixKling ok。那是什么样子的?(谢谢)传入参数a在哪里使用?a
是一个字符串。字符串没有.find()
方法。
var a = $("div").html();
//console.log(a);
a=a.replace('<u>', '<b>');
a=a.replace('</u>', '</b>');
$("div").html(a);