2种方式获取对象内容

来源:互联网 发布:南方旅游 知乎 编辑:程序博客网 时间:2024/06/10 23:07

This is a heading

This is a paragraph.

This is another paragraph.

图书种类

  • 计算机类
  • 教材类
  • 杂志类
  • 文学类

运动

  1. 篮球
  2. 足球
  3. 羽毛球
  4. 乒乓球
  • foo
  • bar
<html><head>    <script src="Scripts/jquery-1.10.2.js"></script><script type="text/javascript">$(document).ready(function(){// 点击显示  <li class = "my_love" title="sport">乒乓球</li> 这个对象的内容,使用两个方式。    $("#hide").click(function() {        var a=document.getElementById("pp").innerHTML;        alert(a);        var b=$("li#pp").text();        alert(b);    });});</script></head><body><h2>This is a heading</h2><p>This is a paragraph.</p><p>This is another paragraph.</p><h3>图书种类</h3><ul type="circle"><li >计算机类</li><li>教材类</li><li>杂志类</li><li id = "my_love">文学类</li></ul><h3>运动</h3><ol ><li>篮球</li><li>足球</li><li>羽毛球</li><li class = "my_love" title="sport" id="pp">乒乓球</li></ol><ul><li id="foo">foo</li><li id="bar">bar</li></ul><button id="hide" type="button">显示</button></body></html> 

0 0