javascript - Passing parameter to @Url.Action based on jquery hasClass output -
i trying pass integer parameter url.action based on hasclass output of jquery. below invalid syntax.
<li class="myclass"> <a href="@url.action("setactionmode", "home", new { enable = $(this).find('i').hasclass("fa-check") ? 0 : 1 })"> <i class="fa fa-check"></i> debug mode </a> </li>
what correct syntax above or there easy way this?
i'd should 'interrupt' link clicking, construct url , go url.
$(".myclass a").click(function(event) { event.preventdefault(); var url = $(this).attr('href'); // here whatever makes sense url = url + "?enable=" + ($(this).find('i').hasclass("fa-check") ? 0 : 1) window.location.href = url; });
Comments
Post a Comment