我已经用输入元素的php打印了回显,我需要使用jquery获取点击事件ID。以下是我尝试获取的代码
API.php(使用ajax将元素反射到index.php):
echo"<input type='submit' id='something' value='accept me'/>";
index.php(需要在点击事件中获取id =“ something”):
$("#something").click(function(){
alert("hi");
//doesnt work
});
为什么它不起作用?请建议
自行编写onclick()
函数input
。会工作的。
有关更多信息,请单击“添加”。单击“提交”按钮-堆栈溢出
<form ... >
.
.
<input type='submit' id='something' onclick="return showValue();" value='accept me'/>
</form>
<script>
function showValue() {
alert('hi');
return false;
}
</script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句