Discover javascript dom manipulation, include the articles, news, trends, analysis and practical advice about javascript dom manipulation on alibabacloud.com
HTML CREATE TABLE:Instead, the DOM is created by:window.onload=function() { var table=document.createelement (' table '); Table.width=300; Table.border=1;}Use the AppendChild () method to add a table's THEAD, tr,th. Such as:var thead=document.createelement (' thead '); Table.appendchild (thead);As you can see, creating tables using the DOM is tiring.Here's a look at how to get tabular data using th
elementElement.srcThe above method can be found to get some object properties and can be implemented using DOM Core or html_dom implementation, compared to the html_dom implementation is relatively short, but it can only be used to work with Web documents.3.css_domCss_dom is a CSS-based operation, in JavaScript in China, the main function of Css_dom technology is to get and set the various properties of th
dom|xml| Conversion
This article briefly describes the concept and internal logic structure of DOM, which describes the Java implementation process of DOM document manipulation and XML file conversion.
1. Introduction to Dom
Currently, the consortium has introduced the speci
Java implementation of dom|xml| conversion DOM document manipulation and XML file conversion
[Author: Guo Hongfeng Add Time: 2001-10-19 8:16:09]
Guo Hongfeng (ghf_email@sohu.com)
Introduction: This paper briefly describes the concept and internal logic structure of DOM, and gives the Java implementation process
// location.href = ' http://www.imdsx.cn ' // " Span style= "COLOR: #008000" > redirect Location.reload () // refresh location.href = Location.href // refresh TimerSetInterval (function, time)//set the timer to execute once every timeclearinterval (intervalobj)//Clear Timer functiontimeinterval () {varSetint = SetInterval (function() {Console.log (1); //execute once to end a scheduled taskclearinterval (Setint)},1000)} setTimeout (function, time)//set the timer, after the page lo
This article briefly describes the concept and internal logic structure of DOM, which describes the Java implementation process of DOM document manipulation and XML file conversion.
1.DOM Introduction
Currently, the consortium has introduced the specification DOM level 2 o
* Example:element.parentNode.setAttribute ("id", "Bannerul");3. Create a NodeCreateElement ()//Create an element with a label named TagNamecreateTextNode ()//Create a text node that contains textual textCreatedocumentfragment ()//Create Document fragmentation node* Example:document.createElement ("P");* Example:document.createTextNode ("Hellow World");* Document.createdocumentfragment () is to save the use of DOM. Each
property (Ie10 below) Add a method Add (Class1, Class2, ...) to add one or more class names to the element. Use the [JavaScript] view plain Copy to view the code slices on codes to derive to my Code slice document.getElementById ("id"). Classlist.add ("A", "B", "C" ) ); Added three classes to DOM object if you need to erase all of the original, re-add the method of using the assignment [
instances.Htmlcollection:getelementsbytagname,getelementsbyclassname,getelementsbytagnamens, Document.forms and so on are returning htmlcollection instances.NamedNodeMap: Represents a collection of attribute node objects, Ele.attributes returns NAMEDNODEMAP instancesQueries that run in real time when the DOM document is accessed, so the following code causes an infinite loop.var divs = document.getelementsbytagname (' div '), I,div; for (i = 0;i) {
first, the basic Operation
1.html ()
Use the HTML () method to read or set the InnerHTMLof the element.
is the equivalent of a innerhtml inside JavaScript.
2.text ()
Use the text () method to read or set the innertext of the element.
is the equivalent of a innertext inside JavaScript.
3.attr ()
Use the attr () method to read or set the attributes of an element, and to manipulate it with at
; Gets the state of the checkbox true to tick the action individual style style.xxx // Manipulating styles is more granular, manipulating individual style properties, or adding a style property to a label Style.backgroundcolor //Example: Styles in CSS can be connected through "-", in JavaScript, all "-" are removed, "-" capitalization Action property Note: CSS style with-, in JS need to-remove, at the same time will-the first letter in the back, su
listener for each child node.at the same time, this avoids the creation of memory that cannot be reclaimed. Even if you register an event with prototype observe and call stopobserving before deleting a node, you will generate a small amount of memory that cannot be reclaimed, so you should register the event listener for DOM nodes as little as possible .So, when it comes to registering events in the loop, it's time for us to consider the event mechan
them as a component, as we see in the process that two different components are bound to be regenerated, even if their content is very similar. The second revelation is that if you use a similar list to present elements, then the elements can be combined with key as much as possible, thus greatly improving efficiency and avoiding unnecessary performance losses.
How do I use non-dom properties?Examples of dangerouslyRef instance, note that by refere
jquery Gets the parent node, the sibling node, and inserts the content within the node.①$ ("#test1"). Parent ()//②$ ("#test1"). Next ()//Next node ③$ ("#test1"). Append (' Summary: At the time of writing JS, we must first determine whether the JavaScript or jquery, because the two different ways, the method name is not the same, can not be mixed.jquery DOM Element manip
be any kind of node, can use Notetype to judgevar nodes = Ele.children;var nodes = Ele.childnodes;Get list of element attributesvar attr = ele.attributes;Querying child elementsvar els = ele.getelementsbytagname (' TD ');var els = ele.getelementsbyclassname (' highlight ');The first/Last child element node of the current elementVal el = Ele.firstchild;Val el = Ele.lastchild;Val el = Ele.firstelementchild;Val el = Ele.lastelementchild; Next/previous sibling element nodevar el = Ele.nextsibling;
jquery handles DOM element-property manipulation1 //properties of the action element:2$ (' * '). each (function(n) {3 This. ID = This. TagName +N; 4 })5 6 //Get property value:7$ ('). attr (' '); 8 9 //To set the property value:Ten //set a value for a property One$ (' * '). attr (' title ',function(index, previousvalue) { A returnPreviousvalue + ' I am element ' + index + ' and my name is ' + This. ID; - }) - the //setting values for multiple p
The DOM property operation is to read, set, and remove the properties of the DOM element, such as prop (), Removeprop ().1. Prop () 1.1 Get return value using Prop ()Prop () returns the value of the first matching element when it returns a property value.1234567 - - - + -1.2 Use prop () to set the property value 1.2.1 use Prop () to set a single property value1234567 - - the - -The result of the execution i
the address of the current pageWindow.location.href= "http://www.baidu.com"; Change page address, will jump pageWindow.location.hostname: Host name, domain name, site name, available variable receiveWindow.location.pathname: path name, available variable receiveV. Window.status objectsstatus bar to add text to displayWindow.status= "What to display in the status bar"; Set the status bar textAdd:The difference between a carriage return \ R and a newline character \ n: \ r equals Enter, which is
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.