in asp.net mvc view page write this razor code for create the dynamic button:
@foreach(var item in ViewBag.MenuLists)
{
<button id="buttons" value=@item.RecordId >اضافه کردن به سبد خرید</button>
}
and want to when button fire show the value for user for that purpose write this java script code:
$(document).ready(function () {
$("#buttons").click(function () {
var fired_button = $("#buttons").val();
alert(fired_button);
});
});
first dynamic button show the value,but when fire two or higher button dont show me alert,what happen?how can solve that problem?thanks.