var xhReq = new XMLHttpRequest(); xhReq.open(“GET”,linksRaw,false); xhReq.send(NULL); var serverResponse = xhReq.responseText; var tempDiv = document.createElement('div'); tempDiv.innerHTML = serverResponse.replace(// g,''); var plzWork = tempDiv.getElementsByClassName('organizationID')。innerHTML; 的console.log(plzWork);
记录到firebug控制台的'plzWork':-)的值始终为'undefined',而链接代码为
<a class="organisationID" href="orglists.htm">Partner Organisations</a>
我正在使用最新版本的Greasemonkey和FF 3.6编写此脚本
由于
答案 0 :(得分:3)
我不想指出那些琐碎的小细节,因为我没有任何其他想法为什么它不起作用,但是当类名的“organisationID”与S时,你真的使用带有Z的“organizationID”吗?
答案 1 :(得分:1)
tempDiv.getElementsByClassName('organizationID')
返回一个集合,而不是单个元素。
tempDiv.getElementsByClassName('organizationID').innerHtml
然后是非法的。也许你的意思是:
tempDiv.getElementsByClassName('organizationID')[0].innerHtml