Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要使用外部脚本来设置onkeypress具有唯一性的输入属性id。我尝试使用$j('#numret').attr('onkeypress', 'calc();');,但此代码不起作用。有没有办法在外部改变这个属性?
onkeypress
id
$j('#numret').attr('onkeypress', 'calc();');
附加事件监听器:
$j('#req').keypress(calc);
$("#req").keypress(function(event){ calc(); });