62,046
社区成员
发帖
与我相关
我的任务
分享
function f(obj)
{
var btnId=$(obj).Attr("id");
alert(btnId);
}
<script type="text/javascript">
function myfunction(id) {
alert(id);
}
</script>
</head>
<body>
<input type="button" id="b1" onclick="myfunction(id)" value="button1">
<input type="button" id="b2" onclick="myfunction(id)" value="button2">
</body>
</html>
function test(){
var e = window.event;
var target = e.target||e.srcElement;
alert(target.getAttribute("id"))
}
<input type="button" id="t1" onclick="test()" value="t1">
<input type="button" id="t2" onclick="test()" value="t2">