最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery中prepend()方法用法實(shí)例

 更新時(shí)間:2014年12月25日 10:42:43   投稿:shichen2014  
這篇文章主要介紹了jQuery中prepend()方法用法,以實(shí)例形式較為詳細(xì)的分析了prepend()方法的功能、定義及使用技巧,并對比分析了與text()方法的不同之處,需要的朋友可以參考下

本文實(shí)例講述了jQuery中prepend()方法用法。分享給大家供大家參考。具體分析如下:

此方法可向所有匹配元素的內(nèi)部的前面追加HTML內(nèi)容。

特別說明:

此方法是追加內(nèi)容,也就是原來的內(nèi)容還在。
HTML內(nèi)容就是內(nèi)容中可以包含HTML標(biāo)簽,并且能夠被瀏覽器渲染。
文本內(nèi)容是先將內(nèi)容中的html預(yù)定義字符轉(zhuǎn)換成html字符實(shí)體,這樣html標(biāo)簽就不會(huì)被渲染。

語法結(jié)構(gòu):

復(fù)制代碼 代碼如下:
$(selector).prepend(content)

實(shí)例代碼:
實(shí)例一:

復(fù)制代碼 代碼如下:

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://m.fzitv.net/" />
<title>腳本之家</title>
<style type="text/css">
div
{
  height:150px;
  width:150px;
  background-color:green;
  margin-top:10px;
}
</style>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("div").prepend("<b>  好好學(xué)習(xí)</b>");
})
</script>
</head>
<body>
<div>原來內(nèi)容</div>
</body>
</html>[/size]
[size=2]

在原來div內(nèi)容的前面追加內(nèi)容。
實(shí)例二:

復(fù)制代碼 代碼如下:

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://m.fzitv.net/" />
<title>腳本之家</title>
<style type="text/css">
div
{
  height:150px;
  width:150px;
  background-color:green;
  margin-top:10px;
}
</style>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $("button").click(function(){
    $(".html").prepend("<b>好好學(xué)習(xí)</b>");
    $(".text").text("<b>好好學(xué)習(xí)</b>");    
  })
})
</script>
</head>
<body>
<div class="html"></div>
<div class="text"></div>
<button>點(diǎn)擊查看效果</button>
</body>
</html>

通過此實(shí)例大家可以觀察一下html內(nèi)容和文本內(nèi)容的區(qū)別。

希望本文所述對大家的jQuery程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論

历史| 兰坪| 香格里拉县| 新沂市| 银川市| 防城港市| 丰原市| 黄山市| 壤塘县| 龙川县| 弥勒县| 揭阳市| 丘北县| 定安县| 桑植县| 保康县| 和平县| 玉环县| 德化县| 车致| 新巴尔虎左旗| 双峰县| 廉江市| 娄底市| 建湖县| 广河县| 土默特右旗| 余干县| 海原县| 新余市| 浪卡子县| 项城市| 渭源县| 华安县| 若羌县| 汉沽区| 阿拉善左旗| 讷河市| 江安县| 山东省| 澳门|