Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
i want to add new attribute in XML using jquery
for e.g: XML:
new XML i want display as:
<data> <section marked="marked"></section> </data>
from above i want to add marked="marked" attribute using jquery.
marked="marked"
您可以在任何 XML 标记中添加属性,就像在 HTML 中添加一样
首先,您的 XML 保存在任何变量中
var a = '<data><section></section></data>';
编辑
现在你也必须添加这一行,它会正常工作。
a = $(a);
此行将在section标签中添加一个属性
section
a.find('section').attr('marked', 'marked');