yanzilee9292 发表于 2013-2-7 18:52:32

Jquery对HTML操作

1. 改变HTML元素内容
 

<html><head><script type="text/javascript" src="/jquery/jquery.js"></script><script type="text/javascript">$(document).ready(function(){$("button").click(function(){$("p").html("W3School");});});</script></head><body><h2>This is a heading</h2><p>This is a paragraph.</p><p>This is another paragraph.</p><button type="button">请点击这里</button></body></html>  
2. 在HTML元素后面添加内容
 

<html><head><script type="text/javascript" src="/jquery/jquery.js"></script><script type="text/javascript">$(document).ready(function(){$("button").click(function(){$("p").after(" W3School.");});});</script></head><body><h2>This is a heading</h2><p>This is a paragraph.</p><p>This is another paragraph.</p><button type="button">请点击这里</button></body></html> 
 
 
页: [1]
查看完整版本: Jquery对HTML操作