<center><h14>for typing help<a href="help.html"> click here</a></h14></center>
<td valign="top"><center>
//in this line I want to use addEvent instead of onkeyup
<textarea id="ta_in" rows="7" cols="42" onkeyup="get_ml()"></textarea>
<br>
<textarea id="ta_out" rows=7" cols="42"></textarea></center>
</td>
答案 0 :(得分:9)
function get_ml(){
alert('in');
}
var el = document.getElementById('ta_in');
if (typeof el.addEventListener != "undefined") {
el.addEventListener("keyup", function(evt) {
get_ml();
}, false);
} else if (typeof el.attachEvent != "undefined") { //incase you support IE8
el.attachEvent("onkeyup", function(evt) {
get_ml();
});
}
<textarea id="ta_in" rows="7" cols="42" onkeyup="get_ml()"></textarea>