我想在不使用 this
关键字的情况下选择一个元素 id,我在函数中设置了一个参数。该参数有一条消息。
<head>
<script type="text/javascript" src="jquery-1.8.3.js"></script>
<script type="text/javascript">
function check(msg){
alert(msg)
}
</script>
</head>
<body>
<input type="text" id="me" onblur="check('this is test')" />
</body>
</html>
最佳答案
<input type="text" id="me" onblur="check('this is test', this.id)" />
或
<input type="text" id="me" onblur="check('this is test', arguments[0].target.id )" />
关于javascript - 是否可以在javascript中不使用 'this'关键字来获取元素的id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16701738/