What I need to do is get the an element property name and make a post, the post part, I think I can handle, but I'm couldn't do it.
I have a list of items with a loop of CompanyNames:
<div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown">
@{
foreach (var item in List)
{
<a class="dropdown-item" name="@item.CompanyToken" id="selector">
<i class="fas fa-user fa-sm fa-fw mr-2 text-gray-400" id="CompanyId"></i>
@item.CompanyName
</a>
}
}
</div>
and in the JavaScript code I was trying to get the item,CompanyToken
by the id selector, but o success :
<script>
$("#selector").click(function () {
var val = $("selector").attr("name").val();
alert( val);
});
</script>