Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Select elements by CSS selector in JavaScript
#1
The HTML part between the <body></body> tags looks like this:

Code:
<!-- Selecting elements by CSS selector -->

<div id="container">
  <p class="note">This is a note</p>
  <p class="note">This is another note</p>
  <p class="error">An error message</p>
</div>

The JavaScript part of the code looks like this:

Code:
// Selecting elements by CSS selector

let container = document.querySelector("#container");

document.write(container);
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Add elements at the beginning of an array in JavaScript Qomplainerz 0 352 04-04-2023, 07:37 AM
Last Post: Qomplainerz
  Add elements at the end of an array in JavaScript Qomplainerz 0 311 04-04-2023, 07:37 AM
Last Post: Qomplainerz
  Select elements by name in JavaScript Qomplainerz 0 317 04-04-2023, 07:36 AM
Last Post: Qomplainerz
  Select elements by tag name in JavaScript Qomplainerz 0 325 04-04-2023, 07:35 AM
Last Post: Qomplainerz
  Select elements by class name in JavaScript Qomplainerz 0 344 04-04-2023, 07:33 AM
Last Post: Qomplainerz
  Select elements by ID in JavaScript Qomplainerz 0 340 04-04-2023, 07:23 AM
Last Post: Qomplainerz

Forum Jump:


Users browsing this thread: 5 Guest(s)