I'm having trouble using the jQuery delegate function to toggle classes. What I want to achieve is toggling the class of
<li class="unselected-values">
to
<li class="<li class="unselected-values">
when the client clicks on the label. Any ideas on where I'm going wrong? Any suggestions or assistance will be greatly appreciated. Thank you.
<ul class="option-list swatch pockets">
@foreach (var pvaValue in attribute.Values)
{
<li class="unselected-values">
<input id="@(controlId)_@(pvaValue.Id)" type="checkbox" value="@pvaValue.Id" checked="@pvaValue.IsPreSelected" />
<label for="@(controlId)_@(pvaValue.Id)" style="background-image:url(@(pvaValue.MenuIcon))">@pvaValue.Name</label>
</li>
}
</ul>
<script type="text/javascript">
$(document).ready(function() {
$('.option-list swatch pockets').delegate('label', 'click', function(event) {
$(this).parent().toggleClass('selected-value');
console.log($(this).parent);
alert($(this).parent);
return false;
});
});
</script>