从按钮单击jquery获取id

时间:2013-07-04 11:02:09

标签: jquery jquery-ui routes

我想通过点击按钮获取ID ...

控制器:

 //Get
    public ActionResult Details(int id)
    {

        // Get member details for the specified member id
        VasPlan vasplan = _repository.GetVasPlan(id);

        // return this member to the default view
        return View(vasplan);
    }

查看:

 <a href="<%:Url.Action("Details","Employervas") %>"><img src="../../Content/Images/Subscribe now on click.png" class="btn"/></a>

Global.ascx:

   routes.MapRouteLowercase(
         "",
         "employer/details/{id}",
         new { controller = "Employervas", action = "Details", id=UrlParameter.Optional }
         );

在这里,当我点击按钮时,它将从数据库中的第一个获取id ..

如何为此生成jquery代码?请帮帮我..

1 个答案:

答案 0 :(得分:0)

此代码打印出单击按钮的ID。

$("#button").click(function (e) {
    console.log(e.target.id);
})