버튼 클릭시 매개 변수가있는 함수를 호출해야합니다. 주어진 코드 SaveAmount(@item.Name)
에서 함수는 매개 변수 @item
과 함께 호출됩니다. 이름하지만 여기버튼 클릭시 예기치 않은 식별자
Uncaught SyntaxError: Unexpected identifier
즉,이 던지는 오류가 내 HTML 코드입니다 : - 여기
@foreach (var item in ViewBag.countries)
{
<td><button type="button" class="btn-primary" id="cnt" onclick="saveAmount(@item.Name)">Update</button></td>
}
내 기능입니다 : - 당신은 큰 따옴표로 ID를 배치해야
function saveAmount(btnId)
{
alert("hiiii"+btnId);
}
id = cnt는 id = "cnt"와 같아야한다고 생각합니다. –