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(8298)
Test-Driven Development with Java by Alan Mellor(6718)
Data Augmentation with Python by Duc Haba(6631)
Principles of Data Fabric by Sonia Mezzetta(6379)
Learn Blender Simulations the Right Way by Stephen Pearson(6277)
Microservices with Spring Boot 3 and Spring Cloud by Magnus Larsson(6150)
Hadoop in Practice by Alex Holmes(5958)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5806)
RPA Solution Architect's Handbook by Sachin Sahgal(5546)
Big Data Analysis with Python by Ivan Marin(5362)
The Infinite Retina by Robert Scoble Irena Cronin(5240)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(5144)
Pretrain Vision and Large Language Models in Python by Emily Webber(4324)
Infrastructure as Code for Beginners by Russ McKendrick(4082)
Functional Programming in JavaScript by Mantyla Dan(4038)
The Age of Surveillance Capitalism by Shoshana Zuboff(3948)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3798)
Embracing Microservices Design by Ovais Mehboob Ahmed Khan Nabil Siddiqui and Timothy Oleson(3602)
Applied Machine Learning for Healthcare and Life Sciences Using AWS by Ujjwal Ratan(3575)
