給arron這個(gè)類加了背景,為何不起作用?
<!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>
? ? .test1 {
? ? ? ? background: #bbffaa;
? ? }
? ??
? ? .test2 {
? ? ? ? background: yellow;
? ? }
? ? .arron{
? ? ? ? background:red;
? ? ? ? width:500px;
? ? ? ? height:300px;
? ? }? ? ? ?此處的定義為何無(wú)效?
? ? </style>
</head>
<body>
? ? <h2>通過(guò)insertBefore與insertAfter添加元素</h2>
? ? <button id="bt1">點(diǎn)擊通過(guò)jQuery的insertBefore添加元素</button>
? ? <button id="bt2">點(diǎn)擊通過(guò)jQuery的insertAfter添加元素</button>
? ? <div class="aaron">
? ? ? ? <p class="test1">測(cè)試insertBefore,不支持多參數(shù)</p>
? ? </div>
? ? <div class="aaron">
? ? ? ? <p class="test2">測(cè)試insertAfter,不支持多參數(shù)</p>
? ? </div>
? ? <script type="text/javascript">
? ? $("#bt1").on('click', function() {
? ? ? ? //在test1元素前后插入集合中每個(gè)匹配的元素
? ? ? ? //不支持多參數(shù)
? ? ? ? $('<p style="color:red">測(cè)試insertBefore方法增加</p>', '<p style="color:red">多參數(shù)</p>').insertBefore($(".test1"))
? ? })
? ? </script>
? ? <script type="text/javascript">
? ? $("#bt2").on('click', function() {
? ? ? ? //在test2元素前后插入集合中每個(gè)匹配的元素
? ? ? ? //不支持多參數(shù)
? ? ? ? $('<p style="color:red">測(cè)試insertAfter方法增加</p>', '<p style="color:red">多參數(shù)</p>').insertAfter($(".test2"))
? ? })
? ? </script>?
</body>
</html>
2019-04-24
同學(xué),得認(rèn)真檢查代碼了,aaron與arron,兩個(gè)不同,一個(gè)a一個(gè)r