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.
我试图对此进行测试,但我遇到了问题。
我可以使用 jquery 检查 xml 文件中的值吗?根据该值(真/假),将显示新的 div 并隐藏其他 div。
例如。如果 xml 里面有一个带有 True 的标签,jquery 会检查这个并用新的“lightOne”div 换出一个默认 div。
编辑:我无法编辑 xml,只能从中读取
像这样的东西应该可以解决问题
$(function () { $.ajax({ type: "GET", url: "url.xml", dataType: "xml", success: function (data) { var txt = $(data).find('something').text(); // 'something' is your xml tag if (txt === 'true') { // create your div } } }); });