Discover javascript document queryselector, include the articles, news, trends, analysis and practical advice about javascript document queryselector on alibabacloud.com
This article illustrates how JavaScript recursively prints the document hierarchy. Share to everyone for your reference. Specifically as follows: ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 The
The wants this article to help you with your JavaScript programming.
The document's advanced article provides functions for node operations, including: getting nodes, changing nodes, deleting nodes, replacing nodes, creating nodes, adding nodes, cloning nodes, and so on. We can use these functions to dynamically change the nodes of the HTML.
1. JavaScript
calls in the 2.body body
The above is a small series of JavaScript for everyone to bring the d
programmer once used this event to make it difficult for visitors to leave the page. Each time a visitor tries to close the page, a new window appears and returns to the page. However, you can also use this event to do some good things. For example, a program can warn a visitor that he has already started filling out a form but has not yet submitted it, or that the program can send form data to the Web server to save the data before the visitor exits the page.Text:
Example Analysis of Document hierarchies printed recursively using Javascript
This Document describes how to print Document hierarchies recursively in Javascript. Share it with you for your reference. The details are as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13
javascript-action on the contents, properties, styles of a Document object (top)I. Contents of operation1. InnerHTML used to set or get object initiation and content within the hormone tag (identify HTML tags)2. InnerText used to set or get object initiation and content within the hormone tag (IE)Textcontent used to set or get object initiation and content within the hormone tag (FF)3. outerHTML is used to
Javascript obtains the relative path of the current document. Function frelativepath (srelative ){
// Shawl. Qiu code, return string
VaR Surl = Document. url;
Surl = Surl. Replace (/^ .*? \: \/[^ \/] +/, ""). Replace (/[^ \/] + $ /,"");
If (! Srelative) {return Surl ;}
If (! // $/. Test (Surl) {Surl + = "/";}
If (/^ \. \. \/. Test (srelative )){
VaR Re = n
How to output information in JS1. Document Flow outputdocument.write (' Hello ');2. Output Information box modal dialog boxWindow.alert (' to output the displayed content '); or alert (' to output the displayed content ');alert (n);3. Information Confirmation Boxvar f = window.confirm (' Whether you want to enter the Sina Network '); Confirm ("");if (f) {Location.href = ' http://www.sina.com.cn ';}4. Prompt input BoxWindow.promptvar n = window.prompt
It is of great help for looping the DOM of batch page operations! Use the document fragment processing, append it at one time, and use the native javascript statement to operate document. createDocumentFragment (). To put it bluntly, it is to save the use of DOM. Every JavaScript operation on DOM changes the realizatio
JQuery $ (document). ready () and JavaScript onload eventsJQuery $ (document ). ready () and window. onload according to the ready () method API description http://api.jquery.com/ready/ this method receives a function type parameter ready (handler), the role of the method is: Specify a function to execute when the DOM is fully loaded. that is, when the DOM is loa
This article mainly introduces window. onload and $ (document ). the difference between ready () and the example analyzes the differences between the two in the use of page elements. For more information, see the example in this article. onload and $ (document ). ready. Share it with you for your reference. The specific analysis is as follows:
Window. onload is a function in
Purpose of this chapterThe authors cite the first example of dynamically creating a list of abbreviations (abbreviation) for a Web page. As you know, we can use Specific stepsWe can do it in three steps:
Traverse document for information
Create label wrapper information
Inserting tags into a WEB document
The specific JS code is as follows:1 //JavaS
JavaScript gets all the pictures of the documentfunction UpdateUI () {var IMGs = document.getelementsbytagname ("img");For (Var i=0, len=imgs.length i Imgs[i].title = Document.title + "image" + i;}var msg = document.getElementById ("msg");msg.innerhtml = "Update complete."}
This function may seem completely fine, but it has three reference global document objects. If there is a page on the
The number of i
A small application of the xml document Conversion Program. several lines of code are used to generate a pie chart. Source code packaging is provided. Source Document, pie chart data
The Code is as follows:
Proportion of each indicator
Person
Indicator 1
50
1
Metric two hundred and fifty-tw
This example describes how JavaScript adds a DOM node to a document. Share to everyone for your reference. Specifically as follows:
Here is a comparison of the two methods: the first is to create all the nodes, and then add to the document mode of the runtime; the second: Add an empty container to the document, and th
is set to visual document.all.odiv.style.display= "none"//layer is set to hide Span style= "FONT-SIZE:16PX;" >document.getelementid ("Odiv")//by Getelementid referencing object document.getelementid (" ODiv "). Display= "None" /*document.all represents a collection of all objects in document only IE supports this attribute, so it is also used to determine the type of browser */ 4 properties of a Layer objectdocument.getElementById ("ID")
First, create an html file and write a FileUpLoad and button control.
The Code is as follows:Copy codeThe Code is as follows:
Then, write a javascript OpenFile method.
The Code is as follows:Copy codeThe Code is as follows:Function OpenFile (){If (document. getElementById ("flUpload"). value. toUpperCase (). indexOf (". XLS ")! =-1){Var objExcel;ObjExcel = new ActiveXObject ("Excel. Application ");ObjExcel.
With the specified ID attribute
With the specified Name property
With the specified tag name
With the specified CSS class
Matches the specified CSS selector
selecting elements by IDvar section1 = document.getElementById ("Section1")Note: In browsers that are below the IE8 version, getElementById () is not case sensitive to the ID of the matching element, and also returns the element that matches the name attribute.Select elements by nameUnlike the ID, the Name property is v
Cookies are sometimes very helpful to our users, for example, for sites that are not particularly important, such as the company's Test platform, and to manually enter a username and password for each login.Very cumbersome. Therefore, in order to introduce other frameworks less, use JS directly in the landing page to write a record user name and password code. And you don't have to remember the password in the foreground.Directly after the first landing directly after the user name and password
First, let's talk about style sheet properties
1. Inline style, which is set in the element style attribute, has the highest level
2. Page style sheet definition that is defined in the page , the second level
3. External link Style sheet file
JavaScript gets and sets the CSS properties of a document element:
1. Gets the style properties that are set in the element style property.
document.getElementById (ID
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.