If the text in div.level
equals the text in variable dlevel
I would like to hide the closest label to that div.
I cannot directly edit the HTML, it is automatically created by the software so I cannot edit the text in div.level. The variable "dlevel" is actually being pulled in from a URL parameter. I can change this parameter (the value of 'dlevel') as it may be an issue with it containing '$'. However, this needs to be versatile so that if the parameter is 50 the label for 50 is hidden and not the label for 500 and vice versa. Any help would be greatly appreciated.
var dlevel = '$50';
$('div.level').filter(function () {
return $(this).text() == dlevel;
}).closest('label').hide();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script>
<div class="level-container">
<label>
<div class="level">
$50
</div>
</label>
</div>
<div class="level-container">
<label>
<div class="level">
$100
</div>
</label>
</div>
<div class="level-container">
<label>
<div class="level">
$500
</div>
</label>
</div>