Home >Web Front-end >HTML Tutorial >Detailed introduction to the use of this in html tags

Detailed introduction to the use of this in html tags

高洛峰
高洛峰Original
2017-03-06 15:44:532145browse

Many friends are unfamiliar with this in the html tag. The example in this article is that after inputting characters into the text box through the keyboard, the pressed characters will be displayed when the button is lifted. For example:

The code is as follows:

<html> 
<head> 
<script type="text/javascript"> 
function showHint(str){ 
alert(str) ; 
} 
</script> 
</head> 
<body> 
<input type="text" onkeyup="showHint(this.value)"/> <!--此处,在html标签中的this代表的是此标签--> 
</body> 
</html>


The running result is: after inputting characters into the text box through the keyboard, when the key is lifted (that is, when the keyup event occurs), the pressed character is displayed.

For more detailed introduction to the use of this in html tags, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn