当前位置: 代码迷 >> HTML/CSS >> jquery html() 与 text() 差异
  详细解决方案

jquery html() 与 text() 差异

热度:540   发布时间:2012-10-24 14:15:58.0
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()结果:

你最喜欢的水果是?
  相关解决方案