I am developing a project using asp.net web api and incorporating jquery template within it.
while ready
$('a').click(function () {
debugger;
// removing the selected class from all anchors
$('.row a').removeClass('selected');
// Adding the selected class to the currently clicked anchor
$(this).addClass('selected');
});
<div class="row">
<div class="span3">
<!-- Injecting dynamic data from script GroupTypeTemplate -->
</div>
</div>
<script id="GroupTypeTemplate" type="text-html">
<nav id="options" class="work-nav">
<ul id="filters" class="option-set" data-option-key="filter">
<li>
<a onclick="getGroupById('${Id}')" data-option-value="*">${TypeName}</a>
</li>
</ul>
</nav>
</script>
I wish to dynamically set the
class
attribute based on the active menu item
How can I determine which id
is currently active
so that I can assign class="selected"
accordingly?
What is the appropriate syntax to achieve this in jquery template?