使用jquery获取自定义标记(包含冒号)值

时间:2022-04-01 18:57:09

I have one custom tag. I want to set value to that custom tag using jquery. Though it look a silly question i spent more time in searching result for that.

我有一个自定义标签。我想使用jquery为该自定义标记设置值。虽然这看起来很愚蠢,但我花了更多的时间来搜索结果。

My tag is

我的标签是

<error:description code="12345" type="error" result="description" />${description}

Now i want the get that tag and have to pass the values using jquery.

现在我想要获取该标记并且必须使用jquery传递值。

Please help me how to do this.

请帮我怎么做。

I have no things i tried area because i not even know how to start.

我没有尝试过区域,因为我甚至不知道如何开始。

Thanks in advance

提前致谢

2 个解决方案

#1


7  

You need to escape the colon using two back-slashes, so just do

你需要使用两个反斜杠来逃避冒号,所以就这样做

$('error\\:description').attr("result"); //to get result attribute
$('error\\:description').text(); //to get the related text

#2


3  

I think this should do it:

我认为应该这样做:

jQuery("error\\:description").text("your text");

#1


7  

You need to escape the colon using two back-slashes, so just do

你需要使用两个反斜杠来逃避冒号,所以就这样做

$('error\\:description').attr("result"); //to get result attribute
$('error\\:description').text(); //to get the related text

#2


3  

I think this should do it:

我认为应该这样做:

jQuery("error\\:description").text("your text");