Home > Web Front-end > JS Tutorial > body text

js implementation of checkbox full selection and inverse selection example_Basic knowledge

WBOY
Release: 2016-05-16 16:50:20
Original
1188 people have browsed it

Example of selecting all check boxes

Copy code The code is as follows:

function selectAll(form) {
var obj = document.getElementsByName('selectall');
var cks = document.getElementsByTagName("input");
var ckslen = cks.length;
for(var i=0;i if(cks[i].type == 'checkbox') {
cks[i].checked = obj[0] .checked;
}
}
}



Example of selecting or unselecting all check boxes

Copy code The code is as follows:



<script><br>function selectAll(){<br> var checklist = document.getElementsByName ("selected");<br>   if(document.getElementById("controlAll").checked)<br>   {<br>   for(var i=0;i<checklist.length;i )<BR>   {<BR>      checklist[i].checked = 1;<BR>   } <BR> }else{<BR>  for(var j=0;j<checklist.length;j )<BR>  {<BR>     checklist[j].checked = 0;<BR>  }<BR> }<BR>}<BR></script>



全选

1:

2:

3:

4:

5:

6:



js按键事件说明

onClick事件

鼠标单击事件是最常见的事件之一,当用户单击鼠标按钮时。同时onClick指定的事件处理程序或代码将被调用执行。

文件说明

第11行使用 onClick事件弹出警告提示对话框。

onChange事件

onChange事件就是当文本框的内容改变时发生的事件。

文件说明

第11行使用onChange事件,当文本框内容发生改变的时候弹出警告提示对话框。

onSelect事件

onSelect事件就是当文本框的内容被选中时发生的事件。

文件说明

第11行使用onSelect事件,当文本框中内容被选中的时候,警告提示对话框显示的结果。

onFocus事件

onFocus事件就是当光标落在文本框中时发生的事件。

文件说明

第12行使用Onfocus事件,当用鼠标选中第二个文本框的时候,自动触发Onfocus事件,弹出一个对话框。

onLload事件

onload事件是当前的网页被显示时发生的事件。

文件说明

第9行使用OnLoad事件,当打开网页的时候自动打开一个警示框。

onUnload事件

onUnload事件是当当前的网页被关闭时发生的事件。

文件说明

第9行使用onUnload事件,当关闭网页的时候自动打开一个警示框。

onBlur事件

onBlur事件就是当光标离开文本框中时发生的事件。

15 

文件说明

第12行使用onBlur事件,当用鼠标离开第二个文本框的时候,自动触发onBlur事件,弹出一个对话框。

onMouseover事件

onMouseover事件是指当鼠标移动到页面元素上方时发生的事件。、、

文件说明

第10行使用onMouseover事件,当鼠标指向滚动文字的时候,自动触发onMouseover事件。

onMouseout事件

onmouseout事件是指当鼠标离开页面元素上方时发生的事件。文件说明

第10行使用onmouseout事件,当鼠标离开滚动文字的时候,自动触发 onmouseout事件。

onDbclick事件

当鼠标双击鼠标按钮时,产生ondbclick事件。同时ondbclick指定的事件处理程序或代码将被调用执行。

文件说明

第11行使用ondbclick事件弹出警告提示对话框。




Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!