The 120-day 1200-hour pass for the Junior school students. NET (vi)

Source: Internet
Author: User

First recommend a widget: W3cfuns front-end development toolkit

Tidy up some messy points of knowledge.

1,dom for manipulating HTML elements

2,window.location.reload (); Refresh the current page **********

3, Cancel the default event: return false; Example: Preventing replication

Document.body.oncopy=function () {
Alert (' Who asked you to make a copy of the money? ');
return false;
}

4,clipboarddata.getdata (' text ')//Get pasteboard content, text is text format

5,getElementById

Getelementsbyname
var inputs=document.getelementsbytagname (' input ');//Get the label on the page

6, Small memory mode: In HTML, the property and the value of the same, in JS is generally to use true or false to change the value

7, please read the protocol code carefully

<script type= "Text/javascript" >
Onload=function () {
var btnobj = document.getElementById (' btn ');
var i = 5;
var setid= setinterval (function () {
i--;
if (I <= 0) {
Clearinterval (setId);//Clear Timer
Btnobj.value = ' agree ';
btnobj.disabled = false;//Enable button
} else {
Btnobj.value = ' Please read carefully (' + i + ') ';
}

}, 1000);
}

</script>

8, the span into block-level element Display:block, only can have width and height display.

9, dynamically create the element var btnobj= document.createelement (' input ');

Btnobj.type= ' button ';

Focus: Create an element and add it to the parent element where you want it

When added to a DV element: document.getElementById (' dv '). AppendChild (' btnobj ');

When added to Body: document.body.appendChild (' btnobj ');

10, add the new element to the layer before the first element example:dvobj.insertbefore (' btnobj ', ' dvobj.firstchild ');

11. Delete all elements:

while (Dvobj.firstchild) {

Dvobj.removechild (Dvobj.firstchild);

}

12,inntertext and textcontent compatible notation:

if (document.getElementById (' dv '). innertext== ' string ') {
IE wording
Cocument.getelementbyid.innertext= ";
}else{
Firefox notation
Document.getelementbyid.textcontent= ";
}

13, add Class style Document.gelelementbyid (' dv '). Classname= ' class ';

14,js set floating elements compatible notation to use Stylefloat (IE) and Cssfloat (Firefox):

if (typeof (dvObj.style.styleFloat) = = ' String ') {
Dvobj.style.stylefloat= ' right ';
}else{
dvobj.style.cssfloat== ' right ';

}

15,css:cursor Control mouse Style Cursor:pointer small hand

the display and hiding of the 16,***** layer is best to write the style in an inline way. ****** the layer

Display is defined in inline style, then the first click button is not able to get CSS properties

17 to prevent duplicate creation of the same element

if (document.getElementById (' dv ')) {
Document.body.removeChild (document.getElementById (' DV '));
}

18,this.offsetleft+ ' px ';

, position:fixed fixed position relative to window

20,

var reg = new RegExp (/\d+/);//Regular Expression object \d number \d+ once to many
Times

var reg =/\d{5}/g;//Global search mode g

21st

Sample Search Box Code:
onload = function () {
document.getElementById (' txt '). onfocus = function () {
if (this.value = = ' Please enter search keywords ' &&
This.style.color = = ' Gray ') {
This.value = ";
This.style.color = ' black ';
}
};
document.getElementById (' txt '). onblur = function () {
if (this.value = = ") {
This.value = ' Please enter search keywords ';
This.style.color = ' Gray ';
}
};

};

22,

Enter to implement TAB jump
Key Replacement *************
var txts=document.getelementsbyname (' input ');
for (Var i=0;i<txts.length;i++) {
if (txt[i].type== ' text ')
{
Txts[i].onkeydown=function () {//keyboard pressed Event
if (window.event.keycode==13) {
window.event.keycode=9;
}
}
}
}

The 120-day 1200-hour pass for the Junior school students. NET (vi)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.