應用程序接收HTML潛水並創建一個頁面,並將其追加到獲得點擊的鏈接按鈕的ID,所有的按鈕已經綁定到一個功能
我綁定的所有鏈接按鈕的頁面集合中的一個功能應用 這將做不同的任務取決於 頁面的ID現在我有一個問題,當一個網頁有超過一個鏈接按鈕 我需要點擊的按鈕ID
HTML:
<a id="x">x </a>
<a id="y">y </a>
Js:
var btns = [];
$('#page-' + newpages[j].pageID + ' a').each(function() {
btns.push({
id: this.id,
value: this.value,
name: this.name
});
});
for (i in btns) {
$('#' + btns[i].id).bind('click', function() {
test(btns[i].id)
});
// bin all buttons in current page to test()
}
};
};
function test(x) {
var page = $('.ui-page-active').attr('id');
/////////
//here I'm trying to ge the ID of clicked button of that page (each ID means something)
var pos = '';
$('#' + page + ' a').click(function() {
//Get the id of this clicked item
var BID = $(this).attr("id");
alert(BID);
send(BID);
});
這樣的代碼應該被禁止從互聯網上 – crush 2013-02-27 13:31:11
如果你提供一個js小提琴幫助會更容易 – 2013-02-27 13:31:15
你有問題......正確的問題是什麼? – Pandian 2013-02-27 13:31:19