大家好,我需要能够通过多个 ID block0_b7 和 block1_b7 进行搜索。这是我当前的代码:
<script type="text/javascript">
window.onload = function() {
var searchString = "Incident",
pageContent = document.getElementById("block1_b7").innerHTML;
var searchString2 = "Voice Services",
pageContent = document.getElementById("block1_b7").innerHTML;
var searchString3 = "Data Service EVDO-1X & LTE",
pageContent = document.getElementById("block1_b7").innerHTML;
if (pageContent.indexOf(searchString) != -1)
document.getElementById("areas").style.display = "inline";
if (pageContent.indexOf(searchString2) != -1)
document.getElementById("dropdown").style.display = "inline";
if (pageContent.indexOf(searchString3) != -1)
document.getElementById("dropdown2").style.display = "inline";
}
</script> <script type="text/javascript">
var mydropdown = document.getElementById('dropdown');
var mydropdown2 = document.getElementById('dropdown2');
var myareas = document.getElementById('areas');
mydropdown.onchange = function(){
comment_body.value = comment_body.value +'\n'+ this.value;
var f = document.forms[2].submit();
f.submit();
}
mydropdown2.onchange = function(){
comment_body.value = comment_body.value +'\n'+ this.value;
var f = document.forms[2].submit();
f.submit();
}
myareas.onchange = function(){
comment_body.value = comment_body.value +'\n'+ this.value;
var f = document.forms[2].submit();
f.submit();
}
我试过这个:
var x, divArray = ["block1_b7", "block0_b7"];
for (x in divArray) {
if (x) {
var searchString4 = "Incident",
var pageCon = document.getElementById(divArray[x]).innerHTML;
}
我不能使用 jquery,但我有原型 1.7。提前致谢!