這裏我有創建動態按鈕的代碼。click事件有問題。動態顯示JQuery按鈕
在那裏我有
alert("work");
開始與此警報線之上,代碼是行不通的。任何幫助?
更新3
// Creating a checkbox for each category and place it in container:
for (var i in chart.xAxis[0].categories) {
checkboxHtml = '<label><button type ="submit" id="category' + i + '" name="category' + i + '">' + i + '</button></label>'
$('#' + legendContainerId).append(checkboxHtml);
}
// Binding events to checkboxes:
$('#' + legendContainerId + ' button[type ="submit"]').on('click', function() {
var hiddenSeries = [];
var hiddenCategories = [];
// Collecting disabled categories:
$('#' + legendContainerId + 'button[type ="submit"]').each(function (i, submit) {
alert("work");
if (!submit.onselect) {
hiddenSeries[i] = null;
hiddenCategories[i] = ' ';
}
你嘗試過type = button嗎? –
是的,但如何更改checkboxHtml? – user1476956
checkboxHtml?請解釋一下。 – tymeJV