Home  >  Article  >  Web Front-end  >  Common skills for javascript beginners_javascript skills

Common skills for javascript beginners_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:38:011343browse

The examples in this article explain some common techniques used by JavaScript beginners. Share it with everyone for your reference. The details are as follows:

1. Javascript program storage location

In HTML6c04bd5ca3fcae76e30b72ad730ca86d36cc49f0c466276486e50c850b7e4956
HTML93f0f5c25f18dab9d176bd4f6de5d30e9c3bca370b5104690d9ef395f2c5f8d1
*.js file inside

2. Standard format

Put it inside the 6c04bd5ca3fcae76e30b72ad730ca86d36cc49f0c466276486e50c850b7e4956 of HTML. When the browser loads the Body part, it will start executing Javascript

<html>
<head></head>
<body>
<script type="text/javascript">
。。。。。。
</script>
</body>
</html>

is placed between 93f0f5c25f18dab9d176bd4f6de5d30e9c3bca370b5104690d9ef395f2c5f8d1 in HTML, generally used to trigger user events

<html>
<head>
<script type="text/javascript">
。。。。。。
</script>
</head>
<body></body>
</html>

For some shared js methods or other ways to avoid code duplication, you can put the js into the *.js file and introduce it into the html

<html>
<head>
<script src="filepath/*.js"/></script>
</head>
<body>
</body>
</html>

3. Common Events Text Box Focus Events

onblur: lost focus event

onfocus: Get focus event

onchange: Text box text change event

onselect: select text box text event

<input type="text" value="test text!" onfocus="if(value=='test text!') {value=''}" onblur="if(value=='') {value='test text!'}" />
<!-- 初始值为test text! 获得焦点后判断用户无输入将文本框设空 失去焦点时判断为空时设置默认值 -->

I hope this article will be helpful to everyone’s learning of javascript programming.

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