以下文字在你点击连接点时增加了一个阵列的物项,并提出了作为html输出的物项清单。 http://jsfiddle.net/dqFpr/“rel=“nofollow noreferer” http://jsfiddle.net/dqFpr/。
我试图设立一个职能,从名单上删除项目。 并非涉及ice的艰巨任务,但有些点点击删除链接,则引发<条码>测试_功能(条码>)。
Can someone tell me what I am doing wrong, or show me another way of triggering the function? Your help is really appreciated ;-)
<script language="javascript">
$(document).ready(function() {
function test_function( number ) {
/* This function is not triggered, nothing works inside here!! */
}
});
var lines = [];
function update_list( lines ) {
var thecode = ;
for(var i = 0; i < lines.length; i++) {
thecode = thecode + lines[i] + <a onclick="javascript:test_function( +i+ )" href="#">(delete)</a><br /> ;
}
$( div#display ).html(thecode);
}
$( a#new ).click(function() {
lines.push( another line );
update_list(lines);
});
</script>
<div id="display"></div>
<a href="#" id="new">Add a new line</a>