I'm trying to hide a div based on the presence of another div on the page.
Heres my HTML & JavaScript:
// IIFE to enable `$` as jQuery
;
(function($) {
// document ready
$(function() {
$(document).ready(function() {
var $description = document.querySelector("#coach2.et_pb_blurb_description");
if ($description.length) {
$('#coachtwocol').hide();
}
});
})(jQuery);
<div id="coachtwocol">
<div id="coach2">
<div class="et_pb_blurb_content">
<div class="et_pb_blurb_container">
<h4><span>Coach:</span></h4>
<div class="et_pb_blurb_description"></div>
</div>
</div>
</div>
</div>
The idea is to hide #coachtwocol if .et_pb_blurb_description is not present under #coach2 (the div .et_pb_blurb_description is not loaded on to the page if it is not filled in on the back end)
I believe the issue lies in my query selector but I'm not sure what I'm doing wrong with it or how to troubleshoot it.