日期:2014-05-16 浏览次数:20561 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <script src="jquery-1.3.2.js"></script> <script> $(document).ready(function(){ alert($("#showsp").html())//大标签showsp下的所有class 为a的div var html=''; $(".a").each(function(){ html +=$(this).text();//每个class为a的div的text值 }); alert(html) alert($("#showsp [name=a]").html())//默认的会取值第一个 }); </script> </head> <body> <div id="showsp"> <div class="a" name="a">1111</div> <div class="a" name="a">2222</div> <div class="a" name="a">3333</div> <span class="a" name="a">4444</span> </div> </body> </html>