I have this html structure:
JavaScript
x
3
1
<div id="xyz"> </div>
2
<div class="content"> </div>
3
i want to hide the element with class named content given the sibling element id which is xyz , in jQuery i can easily do it like this:
JavaScript
1
2
1
$("#xyz").siblings('.content').css({"dispaly": "none"});
2
how can i achieve the same thing using pure Javascript only ?
Advertisement
Answer
JavaScript
1
2
1
document.querySelector("#xyz + .content").style.display = "none";
2