-1
如何使用JavaScript獲取具有屬性name="html_header"
的元素內容?使用JavaScript根據其屬性獲取元素的內容
這是HTML:
<view name="html_header"> //some content </view>
<view name="html_body"> //some content </view>
這是當前的JavaScript:
var Page = xmlDoc.getElementsByTagName("view");
for (i = 0; i < Page.length; i++) {
if(Page.item(i).getAttribute("name") == 'html_header') {
//some process
}
htmlString += Page.item(i).getTextContent();
}
可能有幫助如果你**定義了'我'**!你的JavaScript錯誤控制檯是否不給你任何錯誤信息? – Quentin 2013-04-29 09:03:52
對不起,我錯過了迴圈 – vishnu 2013-04-29 09:07:11