<html > <head> <title>无标题文档</title> </head> <body> <div class="aaa">你好</div> <div class="bbb" style="display:none;">更改我的属性</div> <div class="aaa"></div> <div class="bbb" style="display:none;">更改我的属性</div> <div class="aaa">你好</div> <div class="bbb" style="display:none;">更改我的属性</div> </body> </html> <script> var arr = document.getElementsByClassName('aaa'),temp = []; var brr=document.getElementsByClassName('bbb'); for(var i = 0;i<arr.length;i++){ temp.push(arr[i].innerHTML) } for(var i = 0;i<arr.length;i++) { if(temp[i]=='你好') { brr[i].style.display="block"; } } </script>