2
空值I有这种散装HTML的:克隆输入,但与用jQuery
<div class="bundle" id="bun">
<div>
<label for="title">title:</label><input name="name" id="name" value="led zeppelin III" type="text">
</div>
<div>
<label for="content">content:</label><textarea type="textarea" cols="100" rows="3" name="content" id="content">composed largely at a remote cottage in wales known as Bron-Yr-Aur, this work represented a maturing of the band's music towards a greater emphasis on folk and acoustic sounds. this surprised many fans and critics, and upon its release the album received rather indifferent reviews</textarea>
</div>
<div>
<label for="url">url for image:</label><input name="url" id="url" value="http://www.bob.co.il/wp-content/themes/CMOTA-1.0/demo-images/3.jpg" type="text">
</div>
<img src="http://www.bob.co.il/wp-content/themes/CMOTA-1.0/demo-images/3.jpg" alt="led zeppelin III" height="272">
</div>
和我使用的克隆()的jquery方法本批量复制用于向形式的末尾:
var newElem = $('#bun' + val).clone().attr('id', 'bun' + newval);
newElem.children('input:first').attr('name', 'title' + newval).attr('id', 'title' + newval);
newElem.children('textarea:first').attr('name', 'content' + newval).attr('id', 'content' + newval);
newElem.children('input:nth-child(2)').attr('name', 'url' + newval).attr('id', 'url' + newval);
$('#bun' + val).after(newElem);
它确实有效,但我只想克隆“bun”元素的内容而没有输入值和图像的src值。我应该如何处理这个问题?
谢谢。
谢谢!像魅力一样工作。 – 2011-04-24 10:46:56
欢迎你。 – 2011-04-24 10:56:56