0

I have a html div as below.

<div class="product-layout">
      <div class="product-thumb">
        <div class="image"> 
          <h1>welcome</h1>
        </div>
      </div>
    </div>

when i use addclass function to the class product layout it is not working.

 $(".product-layout").addClass("dontshow");

This is the way i have specified. Please let me know if there is a solution.

2
  • do you want in onload Commented Feb 7, 2019 at 5:28
  • Show your related code it's hard to guess Commented Feb 7, 2019 at 5:29

2 Answers 2

2

if you want addClass in onload please try this. you should include jquery plugin

$(document).ready(function() {
   $(".product-layout").addClass("dontshow");
});
.dontshow{
  background-color:#f00;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="product-layout">
      <div class="product-thumb">
        <div class="image"> 
          <h1>welcome</h1>
        </div>
      </div>
    </div>

Sign up to request clarification or add additional context in comments.

Comments

0

I have updated class with jquery and please make sure put your script at bottom of your page , mean footer bottom.

$(document).ready(function(){
    $(".product-layout").addClass("dontshow");
});
.dontshow {
background-color: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="product-layout">
        <div class="product-thumb">
          <div class="image"> 
            <h1>welcome</h1>
          </div>
        </div>
      </div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.