我有 10 个按钮,是在单击“创建”按钮时创建的。
当我单击“创建”时如何同时单击所有这些按钮?
function a() {
selectAll();
jQuery(selectAllValues());
};
function selectAllValues() {
for(var i = 0; i < array.length; i++) {
document.getElementById("select" + array[i]).click();
}
};
问题在于按钮已创建但未单击。
最佳答案
像这样使用 Jquery :
$("#select" + array[i]).click();
或者不带循环:http://api.jquery.com/attribute-starts-with-selector/
//Will execute the click event on all element where the id begins by "select"
$('[id^="select"]').click();
关于javascript - 使用 jQuery 创建后如何单击按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17578781/