日期:2014-05-17  浏览次数:20534 次

jquery html() 与 text() 区别
      //获取<p>元素的HTML代码
      $("input:eq(0)").click(function(){
			alert(  $("p").html() );
	  });
      //获取<p>元素的文本
	  $("input:eq(1)").click(function(){
			alert(  $("p").text() );
	  });


<p title="选择你最喜欢的水果." ><strong>你最喜欢的水果是?</strong></p>

?上面html()结果:

<strong>你最喜欢的水果是?</strong>

text()结果:

你最喜欢的水果是?