samedi 22 avril 2017

Hide a dynamic button inside a dynamic element

I've a dynamic div which contains some information and an edit button. But, some of these dynamic divs should be editable.

I'm generating all of these dynamic divs from my array of objects, which also holds the data for objects which have type="external".

Each dynamic div will have a class called 'container' and each dynamic edit button has a class called 'edit-btn'.

So, I've a condition like, if in dynamic div the obj.type="external" then it the edit button should be available else it should be hidden.

How do I achieve this?

Here's my static code:

if(type="external"){
  $('.edit-btn').show();
}else{
  $('.edit-btn').hide();
}
<script src="http://ift.tt/2nSb99o"></script>
<div class="container">
  Company Website: <a href="def.html">
  <button class="edit-btn">Edit</button>
</div>
<div class="container">
  Company Website: <a href="abc.html">
  <button class="edit-btn">Edit</button>
</div>
<div class="container">
  Company Website: <a href="efg.html">
  <button class="edit-btn">Edit</button>
</div>

Aucun commentaire:

Enregistrer un commentaire