Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
Hide element based on attribute value jquery

How can I hide child div based on the attribute value of parent div. I have following markup:

<div class="offerContainer">
    <div class="Offers" producttype="CIP">
        <div class="buttons_wrap"></div>
    </div>
    <div class="Offers" producttype="P">
        <div class="buttons_wrap"></div>
    </div>
    <div class="Offers" producttype="CIP">
        <div class="buttons_wrap"></div>
    </div>
</div>

And I want to hide buttons_wrap only when atrribute value of producttype is "CIP".

Something like:

if($(obj).parents(".offersContainer").find('.Offers').attr('producttype').value == "CIP")
    $('.buttons_wrap').hide();
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

$('.buttons_wrap').each(function(){
    if($(this).parents('.Offers').attr('producttype') == "CIP"){
        $(this).hide();
    }
});

JSFIDDLE Example:

https://jsfiddle.net/Panomosh/kL11m73L/

about 4 years ago · Santiago Trujillo Report

0

Try This custom method

$(function() {
var $offers = $('.Offers');
$offers.each(function() {
var productType = $(this).attr('producttype');
if(productType != "CIP")
{ 
   $(this).children().hide();
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<div class="offerContainer">
    <div class="Offers" producttype="CIP">
        <div class="buttons_wrap"><button>First</button></div>
    </div>
    <div class="Offers" producttype="P">
        <div class="buttons_wrap"><button>Second</button></div>
    </div>
    <div class="Offers" producttype="CIP">
        <div class="buttons_wrap"><button>Third</button></div>
    </div>
</div>

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!