我有一个要求,我要在jsp页面上的<input type="text" value="emailaddress">
中打印所有电子邮件地址。我应该能够编辑该字段,因此在其末尾有一个按钮。但是电子邮件地址可以是任意数量。如何选择以任何数字结尾的按钮
$('#button_1').on("click", function() {
//enter code here
});
$('#button_2').on("click", function() {
//enter code here
});
我正在尝试做类似的事情
$('#button_'[]).on("click", function() {
});
有人可以帮我解决这个问题吗?
最佳答案
CSS通配符:
$("button[id^='button_']").click(function() {
// button elements with id starting with "button_"
// return($(this).attr('id'));
});
$("button[id*='button_']").click(function() {
// button elements with id containing "button_"
// return($(this).attr('id'));
});
关于javascript - 触发点击以id结尾的按钮,以id结尾的按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15490390/