显示或隐藏表中的 XML 标记
我正在尝试执行基本的 if/else 语句来显示或隐藏表中的内容。还需要注意的是,此内容是从 XML 文档提供的。我正在寻找一个名为 的 XML 标签。
我有以下代码,但无法弄清楚如何使其工作。无论我尝试什么,它都不会在页面上显示任何内容。我的逻辑似乎是对的,但我也不是一个伟大的编剧;因此,任何指导将不胜感激。感谢您的时间和帮助。
n = xmlDoc.getElementsByTagName("note")[0].childNodes[0].nodeValue
if (n != NONE){
document.write("<tr>");
document.write("<td colspan='4' id='notation'>");
document.write(y[j].getElementsByTagName("note")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");
}else{
document.getElementsByTagName("note").style.display = 'none';
}
}
....或者如果我打开和关闭 div 的可见性会怎样?:
if (none != NONE){
document.write("<div id='test' style='background-color: #999;'>")
document.write(y[j].getElementsByTagName("note")[0].childNodes[0].nodeValue);
document.write("</div>");
}else{
document.getElementById('test').style.display = 'none';
}
I am trying to do a basic if/else statement to display or hide content within a table. It's also important to note that this content is being fed from an XML document. I am looking for an XML tag called .
I have the following code and cannot figure out how to make this work. Whatever I try, it displays nothing on the page. My logic seems right, but I'm also not a great script writer; so any guidance would be greatly appreciated. Thank you for your time and help.
n = xmlDoc.getElementsByTagName("note")[0].childNodes[0].nodeValue
if (n != NONE){
document.write("<tr>");
document.write("<td colspan='4' id='notation'>");
document.write(y[j].getElementsByTagName("note")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");
}else{
document.getElementsByTagName("note").style.display = 'none';
}
}
....or what if I toggle the visibility of a div on and off?:
if (none != NONE){
document.write("<div id='test' style='background-color: #999;'>")
document.write(y[j].getElementsByTagName("note")[0].childNodes[0].nodeValue);
document.write("</div>");
}else{
document.getElementById('test').style.display = 'none';
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
下面我给出了一个示例,book.xml页面写在下面,你可以检查一下。
Below i give a sample example.book.xml page is written below.you can check it.
对于那些感兴趣的人,我的条件是不正确的。本来应该是这样的:
For those interested, my condition was incorrect. It should have been something like this: