0
我有一個JSFiddle,它似乎應該工作,但它沒有。如何更新jquery中的'onclick'事件?
function copyform(curnum){
if(curnum == 3) $('p').html('Thank You!')
var num = $('form').length;
var newNum = new Number(num + 1);
// create the new element via clone(), and manipulate its ID using newNum value
var newElem = $('#form'+curnum).clone().attr('id', 'form' + newNum);
//
//this is where I need to update the onclick to copyform('+newNum+')
$('#form'+newNum+' input').attr('onclick', 'copyform('+newNum+')');
// insert the new element after the last "duplicatable" input field
$('form').after(newElem);
}
我只是需要幫助實現onclick
函數。這是一個更大更復雜的程序的一部分,這將是一個很好的例子。任何和所有的幫助非常感謝!
精心製作的,什麼是你想達到什麼目的? – Grigor 2012-02-24 22:01:18
爲什麼在世界上你會使用jQuery,但堅持使用onClick屬性?使用事件監聽器。 – 2012-02-24 22:01:42
哦,不,你爲什麼要這樣綁定點擊處理程序?你完全錯過了jQuery的觀點嗎? – 2012-02-24 22:02:14