This is my code. When I click on click1 I need to empty the table that is in next div. is it possible to empty that table by using closest siblings using jquery.
i am using
obj = $(this);
obj.siblings('table').empty();
<div>
<div class="dropdown busBook">
<a class="triggerBook listItemBook" data-toggle="dropdown" href="javascript:void(0)">Click here</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li><a class="emptytable" href="javascript:void(0)" >click1</a></li>
<li><a class="emptytable" id="Tele" href="javascript:void(0)">click2</a></li>
<li><a class="emptytable" " href="javascript:void(0)">click3</a></li>
</ul>
<form>
<input type="hidden" value="<%= user.id %>" i name="user_id" title="Consulting" />
</form>
</div>
</div>
<div class="row hide">
<div class="col-md-12">
<div class="bookhere">
<div id="table-wrapper"><div id="table-scroll">
<a class="next pull-right" id='next_id' href="#">next</a>
<input type="hidden" value="<%= user.id %>" name="user_id" />
<div class="clearfix"></div>
<input type="hidden" value="<%= Date.today + 7.days %>" name="next" />
<table class="table table-bordered table-condensed" id='table_id'>
<tr>
<% (Date.today..Date.today + 8.days).first(7).each do |display| %>
<th><%= display.strftime("%a") %>(<%= display.strftime("%d/%m") %>)</th>
<% end %>
</tr>
<tr><td>Date here</td></tr>
</table>
</div>
</div>
Based on your HTML markup, you can use:
$('a.emptytable').closest('div.dropdown').parent().next().find('table').empty();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With