There are two ways to make a new element in the DOMElement.appendchild () Adds a new child node to the element as the last child node.Node.appendchild (new Node object)1. Create a new element createelement2. Create a new text createTextNode3.
Append () and insert ()Add new ElementNow, there are 3 students in the class:>>> L = [' Adam ', ' Lisa ', ' Bart ']Today, the class transferred to a new classmate Paul, how to add new students to the existing list?The first option is to append the
Thankfully, Sjoerd Visscher created the "HTML5 enabling JavaScript", "The Shiv":The code above is a comment, but versions previous to IE9 would read it (and understand it).Adding New Elements to HTMLYou can add any of the new element to the HTML
jquery1.10. Live () method, add an. On () method to bind the event to the element, here is a good example, you can refer to the followingjquery1.10. Live () method, add an. On () method to bind an event to an element, as follows: the On
Function insertafter (newelement,targetelement) { //inserts a new element behind an existing element, which is a general-purpose function var parent = Targetelement.parentnode;if (parent.lastchild == targetelement)
How jquery adds a new element node:In native JavaScript, you can create an element node using the Createlement () function, which describes how to create an element node with jquery.The code is as follows:Scripttype= "Text/javascript"> $(function(){
After adding a new element event, rebind
//unbind ();
Bind ();
Resolves the new element event binding problem for jquery, implementing the rebind () functional function
bind () {
$ ("A[name= ' Columnsel ']"). Bind ("click", Function () {
$
Jquery1.10 away. The live () method adds an. On () method to bind an event to an element, as follows:
On (EVENTS,[SELECTOR],[DATA],FN)
Copy Code code as follows:
$ ("#dataTable tbody tr"). On ("click", Function (event) {
Alert ($ (this).
1 2 create a new HTML element3 1. Create a new element4 2. Create a new node5 3. Append Nodes6 4. Append a new element to an existing element7 -8 HTML>9 Body>Ten One DivID= "Div1"> A PID= "P1">This is a paragraphP> - PID= "P2">This is another
For example, to do an AJAX read the message list, each message has a Reply button, class is "reply", if you are using $ (". Reply"). Click (function () {//do something ...}), Presumably after the return button in the list that was loaded with Ajax,
JS event monitoring and CSS is not the same, CSS as long as set the style, whether the original or new additions, have the same performance. Instead of the event listener, you must bind each element individually to the event.
A common example is
For example, to do an AJAX read the message list, each message has a Reply button, class is "reply", if you are using $ (". Reply"). Click (function () {//do something ...}), Presumably after the return button in the list that was loaded with Ajax,
JS event monitoring and CSS is not the same, CSS as long as set the style, whether the original or new additions, have the same performance. Instead of the event listener, you must bind each element individually to the event.A common example is when
Review
// Html
XX
AA
BB
// JS
$ ('. DV'). Find ('ul ')-> eq (0)-> Find ('lil')-> each (function (I ){
VaR OBJ = $ (this). Find ('A')-> eq (0 );
$ Em = $ (''); // creates an EM element.
Receivem.html (I );
$ Em. insertbefore (OBJ); /
New Year new elements: Reading, fitness, learning, efficiency, thinking, thinking.Reading: Books are the ladder of human progress, self-evident the importance of reading.Fitness: Good body is the capital of revolution, blood Man, should have the
In fact, I want to put it first, so that I can use begin to access this new element-I am working on a connection pool and want to put the connection I just used up at the beginning, in this way, it can be used frequently, and those that are not
Event binding by listening for matching child elements under a parent container $ ('. Add '). On (' click ', Function () {$ (' #test1 '). Append (' "); $ ('. Btn '). On (' click ', Function () {});});The solution of invalid JS for dynamic new
New properties:
Contenteditable, DesignMode, Hidden, spellcheck;
New elements:
Document elements
: Independent articles
: chunking the contents of a page
: Define the navigation bar on the page
:
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.