我是jQuery的新手.说实话,这是我的头几天.
还有我的第一个问题.
$(document).ready(function() {
$('span.head-span').parent().addClass('head-h').append('<div class="clx" />')
});
Run Code Online (Sandbox Code Playgroud)
结果我有这个
<h1 class="head-h"><span class="head-span">This is Some Heading</span><div class="clx"/></h1>
Run Code Online (Sandbox Code Playgroud)
我需要在jQuery中做什么,所以我的.clx会出现在.像这样
<h1 class="head-h"><span class="head-span">This is Some Heading</span></h1><div class="clx"/>
Run Code Online (Sandbox Code Playgroud)
非常感谢你提前.
Sim*_*Fox 14
您应该能够使用after()而不是使用append()
$('span.head-span').parent().addClass('head-h').after('<div class="clx" />')
Run Code Online (Sandbox Code Playgroud)