
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM nextSibling Property
The HTML DOM nextSibling property returns the element node which is immediately following specified element node.
NOTE: This property does not ignore text and comment nodes.
Following is the syntax −
Returning nextSibling node
nodeList.nextSibling
Let us see an example of HTML DOM nextSibling property −
Example
<!DOCTYPE html> <html> <head> <title>HTML DOM nextSibling</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } ul{ width: 30%; margin: 0 auto; } </style> </head> <body> <form> <fieldset> <legend>HTML-DOM-nextSibling</legend> <h3>Grocery Store</h3> <ul> <li>Monday</li> <li>Tuesday</li> <li>Wednesday</li> <li>Thursday</li> <li>Friday</li> <li id="Today">Saturday</li><li>Sunday</li> //Do not add whitespace between <li> elements as lastSibling does not ignores whitespaces </ul> <input type="button" onclick="getTimmings()" value="Get Sale Day"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var dayToday = document.getElementById("Today"); function getTimmings() { divDisplay.textContent = 'Sale on last day of week: '+dayToday.nextSibling.textContent; } </script> </body> </html>
Output
Before clicking ‘Get Sale Day’ button: −
After clicking ‘Get Sale Day’ button −
- Related Articles
- HTML DOM tagName Property
- HTML DOM accessKey Property
- HTML DOM activeElement Property
- HTML DOM name Property
- HTML DOM nextElementSibling Property
- HTML DOM nodeName Property
- HTML DOM nodeType Property
- HTML DOM nodeValue Property
- HTML DOM offsetHeight Property
- HTML DOM offsetLeft Property
- HTML DOM offsetParent Property
- HTML DOM offsetTop Property
- HTML DOM offsetWidth Property
- HTML DOM textContent Property
- HTML DOM title Property

Advertisements