Jquery – If hasClass then addClass to parent node
I am trying to add new class to the parent class if nodes has a certain class. $(document).ready(function() { if ($(".row").hasClass("lock-icon")) { $(".row .lock-icon").parent(".content-box").addClass('locked-badge'); } }); .locked-badge { opacity: 0.2; cursor: not-allowed; } <div class="col-md-6 mb-5"> <div class="content-box"> <div class="row">…