2

EDIT : I use Bootstrap as well. No console errors

I have a button which hides and un-hides a div

<button type="button" class="btn btn-info" data-toggle="collapse" id="showBtnFullDetails" data-target="#showFullDetails" value="Dynamic">Show Responses</button>

and the Div

<div id="showFullDetails" class="collapse out">Some Data</div>

Then I have this onclick event

$("#showBtnFullDetails").click(function() {
  alert("Test");
});

But it doesn't work. On other buttons it works. Is there some explation to this? I need this button to work to hide and unhide that div as well I need it to accept onclick function coz I'll be doing other task.

j08691
  • 204,283
  • 31
  • 260
  • 272
jackhammer013
  • 2,295
  • 11
  • 45
  • 95

1 Answers1

3

Use event delegation and see if that catches it.

$(document).on("click", "#showBtnFullDetails", function() {
  alert("Test");
});

Or I believe there is a shown event

$("#showFullDetails").on("show.bs.collapse shown.bs.collapse",function(event){
    alert("Test");
});
epascarello
  • 204,599
  • 20
  • 195
  • 236