-1

In jquery we put select child element using like this

$('.parentClass .childClass')....

is there any way to select child class using parent class in javascript

Karan Adhikari
  • 485
  • 1
  • 5
  • 16

3 Answers3

2

For Javascript try this

document.querySelectorAll('.parentClass .childClass')

You can use css selector as argument in this function. This function not supported in lower version of IE

Pratik Parekh
  • 447
  • 4
  • 19
0

html:

<ul class="example">
  <li class="child">Coffee</li>
  <li class="child">Tea</li>
</ul>

javascript:

var list = document.getElementsByClassName("example")[0];
list.getElementsByClassName("child")[0].innerHTML = "Milk";
Gokul
  • 931
  • 7
  • 16
0

The question is not clear but if you want to get all nested child elements which has class, this can be work:

$("parentElementSelector").find("[class]")

But if you want to just next child elements you can use this:

$("parentElementSelector").children("[class]")