I have this html code. I'm trying to show a table when the button is clicked. It works when button is outside all the divs. But I need to write the click event when button is still inside.
Here's my HTML code:
<div class="col-md-4 col-sm-4 col-6">
<div class="view overlay hm-white-slight">
<img src="images/doctor-new.png" class="img-fluid img-thumbnail" alt="">
<p><strong class="text-success">All Appointments</strong></p>
<button id="click" class="btn btn-success">Show</button>
<a >
<div class="mask"></div>
</a>
</div>
</div>
And here's my jquery code:
<script>
$(document).ready(function (){
$('#appointment-table').hide();
$('div.col-md-4 button#click').click(function (){
$('#appointment-table').fadeToggle('slow');
});
});
</script>
But it is not working... Can anyone please help?
jquery selectors)appointment-tablewithin the code provided. In the following JSFiddle, I have changed nothing except for adding a div with the idappointment-table: jsfiddle.net/066oodg8/1$("#click")and<button id='click'/>and there is only one button with that ID (because IDs must be unique within the document) and your html is not added dynamically (ie after your doc ready) - then it will work anywhere. So if it's not working, one of the above is not correct and your question does not make it clear which one.