Within the realm of styling, there exists an element adorned with the .bg class. Its aesthetic instructions are described as follows:
.bg {
width:100%;
}
.bg:before {
position: absolute;
content: '';
background: rgba(0,0,0,0.5);
width: 100%;
height: 100%;
}
Moreover, there exists a JavaScript directive that mandates the height of the .bg class:
$(".bg").height($(document).height());
However, the objective is to assign the height of $(document).height() to .bg:before instead. How can such a task be accomplished using JavaScript? This is because the code
$(".bg:before").height($(document).height());
does not yield the desired outcome.
Your guidance and assistance are greatly appreciated