-5

I am having the following CSS Full selector "body > div > p" I need to fetch the element using the above css selector using javascript/jquery. Is there any built in function available to achive this ?

Anoop AP
  • 50
  • 1
  • 7

1 Answers1

3

Single selection:

document.querySelector('body > div > p')

Multi selection (as array):

document.querySelectorAll('body > div > p')

These were pure JS.

If you want to use jQuery

$('body > div > p')
F.NiX
  • 1,457
  • 3
  • 12
  • 20