0
在下面的示例jQuery中,在顯示克隆的HTML段之前,如何將文本「Remove Frog」更改爲「Remove Frog#99」並添加一個名爲「frog99」的ID 「,其中99是一個測序編號?克隆,附加和修改(青蛙)
<div id='imageBox'>
</div>
<div class="hidden" id='template'>
<span class='alignRight'><a href='#' class='deleteFrog'>Remove Frog</a></span>
<span class='alignRight'><a href='#' class='addFrog'>Add Frog</a></span>
<img src="img/frog.jpg">
</div>
腳本:
var frogCount = 0;
$(document).ready(function() {
// listener: add "live" listener to link
$("#addFrog").live('click', function() {
// Clone hidden template
myClone = $("#template").clone();
// Before showing cloned object, I would like to change text "Remove Frog" to "Remove Frog #99".
// I think it should look something like this,
myClone.("a").text("Remove Frog #" + ++frogCount);
// Also add an id called "frog99", where 99 is a sequential number.
myClone.removeClass("hidden");
$('#imageBox').append(myClone);
});
});
,你的問題是什麼? –