1
我想檢查父div中給定標籤'section'。如果'section'標記不存在,則使用'section'標記包裝子div。檢查給定的div是否在父div
jQuery(document).on('keydown', function(e) {
if (e.keyCode === 34) {
alert('hello');
jQuery(".child").wrap("<section class='panell'>Hello</section>");
}
});
.panell { border:1px solid black }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="parent" style="background-color:red;min-height:100vh;">
<div class="child">
World
</div>
</div>
我要檢查的部分標籤是在課堂上「父」與存在和部分標籤附加包裹孩子的div與
我有一個很難理解的問題。 –