Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67411

How to get a element name in html for ASP.NET MVC

$
0
0

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>

Viewing all articles
Browse latest Browse all 67411

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>