2
In jquery:
<script>
$( "#main article:nth-child(3) .postSnippet" ).css("display", "block");
</script>
How would I look in pure JS?
2
In jquery:
<script>
$( "#main article:nth-child(3) .postSnippet" ).css("display", "block");
</script>
How would I look in pure JS?
4
The selector is the same, what changes is the way you go through the element(s) and apply the desired style. Example:
var e = document.querySelectorAll('#main article:nth-child(3) .postSnippet');
for (var i = 0; i < e.length; i++) {
e[i].style['display'] = 'block';
}
However, wouldn’t it be easier to add a style to your CSS to do this? Example:
#main article:nth-child(3) .postSnippet {
display: block;
}
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.