JS循环网页元素,手动触发事件 for (i = 0 ;i < document.all.tags( " input " ).length;i ++ ) { if (document.all.tags( " input " )[i].type == " checkbox " ) { if (selected && ! document.all.tags( " input " )[i].checked ) document.all.tags( " input " )[i].click(); else if ( ! selected && document.all.tags( " input " )[i].checked ) document.all.tags( " input " )[i].click(); } } 通过document.all.tags对HTML元素进行选择,这样就可以通过循环遍历到所有自己想找的元素,