Html:1. Do not use document.write when the document is loaded, this will create a new DOM object and the original element will be overwritten.2, the acquisition of elements, through the getElementById; Getelementbytag ("P") (first of the same element)3. Change the attribute. getElementById (' id '). href= "www.baidu.com";Css:1. Syntax document.getElementById (ID). Style.property = new Style; document.getElementById (' divID '). Style.width = ' 50px
the DOM operation of JSDom:document Object ModelBom:bowers (browser) Object ModelFind the element: Var A=document.getelementbyid ("id"), put the found element in the variable;ID selector: document.getElementById ("id"), according to the ID, find at most one;Class selector: Document.getelementclassname ("name"), according to ClassName, find out the array;Tag Selector: document.getelementtagname ("name"), based on the name of the tag, find the array;Nam
HTML DOM (Document Object model)When a Web page is loaded, the browser creates a Document object model for the page.The HTML DOM model is constructed as a tree of objects.Windows Object Operations
window.open ()-Open a new window
Window.close ()-Close the current window
1.windows.open ("Part I", "second part", "Part Three", "Part IV")The first part: Write page address URLThe second part: _
", "toolbar=no width=300 height=200 top = left=500"); = window.open ("http://www.xinhuanet.com", "_blank", "Toolbar=no width=300 height=200 top=300 left=200"); Window.settimeout ("CC ()", 10000); } Window.settimeout ("OK ()", 5000);(3) Delay execution, open three windows every 5 seconds, open 4 times and then stop.Use in the loop inside call yourself, this use way to pay attention to the conditions of the setting, otherwise it may cause the window has been open, and finally cra
First, document.getElementById () Gets the element node by ID first Apple second Apple function () { var str = document.getElementById ("P1"). InnerHTML; alert (str); // pop up I'm the first Apple }Second, Document.getelementsbyname () Gets the element node according to the name first Apple second Apple function fun1 () { var username = Document.getelementsbyname ("UserName") [0].value;
available.Window.settimeoutFour, Operation styleThis element is first found using the ID of the element and stored in a variable:var a = document.getElementById ("id");You can then manipulate the attributes of the element:A.style. style = ""; Manipulate the properties of this ID style.Styles are styles in CSS, and all styles can be manipulated in code.document.body.style.backgroundcolor= "COLOR"; The background color of the entire window.Action style class:a.classname= "style sheet ClassName" A
This article writes about some methods of common and common operation nodes.1. Node Method 1>appendchild ()Add a node to the end of the ChildNodes list, with the syntax var achild = Element.appendchild (achild);It is important to note that if the incoming node already exists in the document, the result is that the node is removed from its original location and then added to the specified location. Cases:var returnednode = somenode.appendchild (somenode.firstchild); Console.log (Returnednode /
1. The page output is document.write (), but it cannot be used in window.onload, otherwise the entire HTML page will be overwritten.2. After getting the object through JavaScript, change the HTML content in the object: document.getElementById (ID). innerhtml=New HTML. 3. Change the object's properties: document.getElementById (ID). attribute=New value.4. Change the object's CSS properties: document.getElementById (ID). style.property=New Style.JavaScript Learning Note (--javascript) syntax
the text content of the//text node or comment node nodeName //element's label name (such as P,span, #text ( Text node), DIV), denoted in uppercase //note, the above 6 methods even element nodes are counted as one node(2) document as an element tree firstelementchild //First child element node lastelementchild //Last child element node Nextelementsibling //Next sibling element node previouselementsibling //Previous sibling element node childelem
element propertiesFor standard attributes such as: ID, event, SRC, and so on. Assign a value directly with a propertyFor non-standard attributes: class, and so on. Use the following method:,GetAttribute () SetAttribute () Hasattribute () RemoveAttribute ()6element.textcontent//can be used to set plain text7. Modify the document treeCreate node: document.createelement () createTextNode ()Insert Node Parent.appendchild (chid) Parent.insertbefore (Child,parent.childnodes[n])//If the child is in th
jquery on the characteristics of the selection and manipulation elements of jqueryJavaScript Select elementsLet's take a look at how we handle element selection without jquery.When JavaScript selects an element, it can get the element based on the ID, and when the ID does not exist, the result is null, and the console reports the script execution error.So the general practice is to first use an if to determ
jquery on the characteristics of the selection and manipulation elements of jqueryJavaScript Select elementsLet's take a look at how we handle element selection without jquery.When JavaScript selects an element, it can get the element based on the ID, and when the ID does not exist, the result is null, and the console reports the script execution error.So the general practice is to first use an if to determ
Niuke's Jquery -- mutual conversion between Jquery and DOM objects and DOM operations, jquerydom
Only jQuery objects can call various functions of the jQuery class library. Similarly, some attributes and methods of
Only jquery objects can invoke various functions of the JQuery class library, while the properties and methods of some DOM objects are not callable on jquery, but essentially the JQuery class library provides functions that contain all D
a 1.jQuery object is an object that is created after wrapping a DOM object through jquery. 2.jQuery objects and Dom objects are converted to each other. good writing style:var $input =$ ("input")the object that jquery gets is prec
elements with the specified HTML or DOM elements.Another method is ReplaceAll (), which is the same as the ReplaceWith () method, except that it reverses the replacewith () operation.
Parcel nodes
Wrap () can be used if you want to wrap a node with other tags. This method is useful for inserting additional structured markup into a document, and it does not break the semantics of the original document.The Wrap () method is to wrap all th
jquery objects converted to DOM objectsjquery provides two ways to convert a jquery object into a DOM object, which is [index] and get (index). Some people might find it strange, how to use subscript, yes, the jquery object is an array object.The following code shows a way t
Advanced jQuery skills-DOM operations and jquery skills domDOMReady event for page loading
The so-called domReady, that is, the document is ready. We all know that operations on dom must be performed only after the dom tree is loaded. How to detect that the
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.