1//Pretend there is a <p> with class "example"
2const myParagraph = document.querySelector('.example');
3//You can do many this with is
4myParagraph.textContent = 'This is my new text';
1// TO select all the h1 from Html
2document.querySelectorAll("h1")
3
4//To select h1 from a particular class or id
5document.querySelector(".className/#id h1")
1var x = $(".yourclass")[0];
2console.log('jq' + x);
3var y = document.querySelector(".yourclass");
4console.log('js' + y);
1<div id="foo\bar"></div>
2<div id="foo:bar"></div>
3
4<script>
5 console.log('#foo\bar'); // "#fooar" (\b is the backspace control character)
6 document.querySelector('#foo\bar'); // Does not match anything
7
8 console.log('#foo\\bar'); // "#foo\bar"
9 console.log('#foo\\\\bar'); // "#foo\\bar"
10 document.querySelector('#foo\\\\bar'); // Match the first div
11
12 document.querySelector('#foo:bar'); // Does not match anything
13 document.querySelector('#foo\\:bar'); // Match the second div
14</script>