标签:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <script src="js/jquery.js"></script> <script> window.onload = function(){ document.getElementById(‘btnok‘).onclick = function(){ //1.匹配索引为3的子元素 //$(‘li:nth-child(3)‘).html(‘test‘); //2.匹配第一个子元素 //$(‘li:first-child‘).html(‘test‘); //3.匹配值具有一个子元素的元素 $(‘li:only-child‘).html(‘test‘); } } </script> </head> <body> <input type="button" id="btnok" value="匹配" /> <hr> <ol> <li>AAAAA</li> <li>BBBBB</li> <li>CCCCC</li> </ol> <hr> <ol> <li>DDDDD</li> </ol> </body> </html>
标签:
原文地址:http://www.cnblogs.com/leigood/p/4903323.html