<!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=utf-8" /> <title>Jquery</title> <script type="text/javascript" src="../Js/jquery1.6.1.js"></script> <script type="text/javascript"> $(document).ready(function() { var ht = $('.toshow li').html(); var te = $('.toshow li').text(); var htte = '这是html()在li的显示结果' + ht + '****' + '<br>这是text()在li的显示结果' + te + '****'; var ht1 = $('.toshow1').html(); var te1 = $('.toshow1').text(); htte += '<br>这是html()在div的显示结果' + ht1 + '****' + '<br>这是text()在div的显示结果' + te1 + '****'; $('.totext').html(htte); }); </script> </head> <body> <div class="toshow"> <ul> <li>sj*</li> </ul> </div> <div class="toshow1">sj*</div> <div class="totext"></div> <div class="result"> 在li下,将会在最后有一个' '空格 </div> </body> </html>