Beyond jQuery by Ray Nicholus
Author:Ray Nicholus
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA
At the top of the preceding code, I’m simply selecting elements needed by our move operation. The last line is the most important one. Since the insertBefore() method is defined on the Node object’s prototype, we must call insertBefore() on an DOM object that implements this interface. In fact, this element must be a parent element of the Node we are moving. Since we are moving the “vanilla” <li> element, we can use its parent—the “flavors” <ul>.
The first parameter passed to insertBefore() is the element we want to relocate: the “vanilla” list item. The second parameter is the “reference node.” This is the Node that will become the next sibling of our target element (the “vanilla” <li>) after the move operation. Since we want to move “vanilla” before “strawberry,” the “strawberry” <li> is our reference node.
We’ve reordered our flavors, but we still need to move the flavors heading and list to the top of our document. We can easily accomplish this goal with the insertBefore() method as well:
1 var headings = document.querySelectorAll('h2'),
2 flavorsHeading = headings[0],
3 typesHeading = headings[1],
4 typesList = document.querySelector('.types');
5
6 document.body.insertBefore(typesHeading, flavorsHeading);
7 document.body.insertBefore(typesList, flavorsHeading);
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
AI & Machine Learning | Bioinformatics |
Computer Simulation | Cybernetics |
Human-Computer Interaction | Information Theory |
Robotics | Systems Analysis & Design |
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(7903)
Hadoop in Practice by Alex Holmes(5688)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5543)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(4560)
Functional Programming in JavaScript by Mantyla Dan(3748)
The Age of Surveillance Capitalism by Shoshana Zuboff(3472)
Big Data Analysis with Python by Ivan Marin(3341)
Test-Driven Development with Java by Alan Mellor(3025)
Blockchain Basics by Daniel Drescher(2933)
Data Augmentation with Python by Duc Haba(2861)
The Rosie Effect by Graeme Simsion(2756)
WordPress Plugin Development Cookbook by Yannick Lefebvre(2698)
Principles of Data Fabric by Sonia Mezzetta(2677)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2616)
Applied Predictive Modeling by Max Kuhn & Kjell Johnson(2524)
The Infinite Retina by Robert Scoble Irena Cronin(2502)
Dawn of the New Everything by Jaron Lanier(2467)
Microservices with Spring Boot 3 and Spring Cloud by Magnus Larsson(2456)
Learn Blender Simulations the Right Way by Stephen Pearson(2441)
![](/ebook_detail_files/space.gif)