I am very much new to Javascript but was hoping someone could advise with the following problem. I have the following div class and a part of the requirement is to hide the entire div and all its sub h2 fields if the {retreat_dates} field is missing, can someone please point me to the right direction?
<div class="grid_3 retreatextradetails">
<h2>Retreat dates</h2>
<p>
{retreat_dates}{date}<br />{/retreat_dates}
</p>
<div class="hr"></div>
<h2>Age range</h2>
<p>{retreat_age}</p>
<div class="hr"></div>
<h2>Fitness level</h2>
<p>{retreat_fitness}</p>
<div class="hr"></div>
<h2>No. of places</h2>
<p>{retreat_places}</p>
<div class="hr"></div>
<h2>Retreat Prices</h2>
<table>
{retreat_prices}
<tr>
<td class="cell_title">{description}</td>
<td class="price">{price}></td>
</tr>
{/retreat_prices}
</table>
</div>
This is the corresponding javascript i am using but it does not work:
</script>
$("#filterTextBox").on("keyup", function () {
var search = this.value;
$(".grid_3 retreatextradetails").show().filter(function () {
return $(".retreat_dates", this).text().indexOf(search) < 0;
}).hide();
});
<script type="text/javascript">
h2and all the child elements! Then whats the point of hidding thesub h2 fields??{retreat_dates}? By "missing" I can only assume that it's populated by some server-side processing. That server-side processing should be where you determine whether or not to emit thedivto the client. It has nothing to do with JavaScript.