第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

return '<div class="' + $(this).text() + '" />';?

<!DOCTYPE html>

<html>


<head>

? ? <meta http-equiv="Content-type" content="text/html; charset=utf-8" />

? ? <title></title>

? ? <script src="http://idcbgp.cn/static/lib/jquery/1.9.1/jquery.js"></script>

? ? <style>

? ? .left div,

? ? .right div {

? ? ? ? width: 100px;

? ? ? ? padding: 5px;

? ? ? ? margin: 5px;

? ? ? ? float: left;

? ? ? ? border: 1px solid #ccc;

? ? ? ? background: #bbffaa;

? ? }

? ??

? ? .right div {

? ? ? ? background: yellow;

? ? }

? ??

? ? p {

? ? ? ? border: 1px solid red;

? ? }

? ??

? ? a {

? ? ? ? border: 1px solid blue;

? ? }

? ? </style>

</head>


<body>

? ? <h2>DOM包裹wrap()方法</h2>

? ? <div class="left">

? ? ? ? <button class="aaron1">點(diǎn)擊,通過wrap方法給p元素增加父容器div</button>

? ? ? ? <button class="aaron2">點(diǎn)擊,通過wrap的回調(diào)方法給a元素增加父容器div</div>

? ? </div>

? ? <div class="right">

? ? ? ? <p>p元素</p>

? ? ? ? <p>p元素</p>

? ? </div>

? ? <div class="left">

? ? ? ? <a>a元素</a>

? ? ? ? <a>a元素</a>

? ? </div>

? ? <script type="text/javascript">

? ? $(".aaron1").on('click', function() {

? ? ? ? //給所有p元素,增加父容器div

? ? ? ? $('p').wrap('<div></div>')

? ? })

? ? </script>

? ? <script type="text/javascript">

? ? $(".aaron2").on('click', function() {

? ? ? ? $('a').wrap(function() {

? ? ? ? ? ? return '<div class="' + $(this).text() + '" />';????

? ? ? ? })

? ? })

? ? </script>

</body>


</html>


正在回答

3 回答

我第一次看也是相同的疑問,但功能卻實(shí)現(xiàn)了,我就猜測(cè)是不是

$('p').wrap('<div>');
$('p').wrap('<div></div>');
$('p').wrap('<div/>');

這三者是等價(jià)的,于是測(cè)試了一下,果然如此

0 回復(fù) 有任何疑惑可以回復(fù)我~

這個(gè)class就沒有起作用

0 回復(fù) 有任何疑惑可以回復(fù)我~

$(this).text()中的this指代元素a,即$("a").text(),意思是a元素,class="'a元素'",類選擇器的值‘a(chǎn)元素’,添加的并沒啥作用。

2 回復(fù) 有任何疑惑可以回復(fù)我~
#1

atlunix

thank you.
2018-09-17 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

return '<div class="' + $(this).text() + '" />';?

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)