码迷,mamicode.com
首页 > Web开发 > 详细

jQuery 文档操作方法

时间:2017-07-17 10:06:06      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:on()   button   jquer   例子   other   htm   内容   read   javascrip   

这些方法对于 XML 文档和 HTML 文档均是适用的,除了:html()。

一、append() 方法

append() 方法在被选元素的结尾(仍然在内部)插入指定内容。

例子:

<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").append(" <b>Hello world!</b>");
});
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>在每个 p 元素的结尾添加内容</button>
</body>
</html>


得出结果

This is a paragraph. Hello world! Hello world! Hello world!

This is another paragraph. Hello world! Hello world! Hello world!

每次点击按钮,都会在元素内容后面添加需要的内容。

 

jQuery 文档操作方法

标签:on()   button   jquer   例子   other   htm   内容   read   javascrip   

原文地址:http://www.cnblogs.com/michellexiaoqi/p/7192719.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!