国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jQuery中after()方法用法實例

2019-11-20 13:36:22
字體:
供稿:網(wǎng)友

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

此方法可向每個匹配元素的外部的尾部追加HTML內(nèi)容。

特別說明:

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

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

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

實例代碼:

實例一:

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

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://m.survivalescaperooms.com/" />
<title>武林網(wǎng)</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").after("<b>  好好學(xué)習(xí)</b>");
})
</script>
</head>
<body>
<div></div>
</body>
</html>

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

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

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://m.survivalescaperooms.com/" />
<title>武林網(wǎng)</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").after("<b>好好學(xué)習(xí)</b>");
    $(".text").text("<b>好好學(xué)習(xí)</b>");    
  })
})
</script>
</head>
<body>
<div class="html"></div>
<div class="text"></div>
<button>點擊查看效果</button>
</body>
</html>

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

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

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 乐都县| 平昌县| 芦溪县| 新民市| 宜阳县| 盐亭县| 永修县| 安多县| 视频| 自贡市| 鄯善县| 伊金霍洛旗| 池州市| 小金县| 隆安县| 灯塔市| 壶关县| 仁布县| 晋江市| 万盛区| 宁河县| 桓仁| 淮阳县| 噶尔县| 东乡族自治县| 清徐县| 凌海市| 大同县| 高台县| 利辛县| 二连浩特市| 延庆县| 哈密市| 威信县| 腾冲县| 扶沟县| 开平市| 台湾省| 济源市| 大连市| 靖远县|