2013-07-04 41 views
0

我想从按钮的点击编号...获得来自按钮点击jQuery的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代码?请帮助我..

+0

没有。我不知道jquery toomuch。我不知道如何把代码从按钮点击检索ID .. – Duk

+0

可能重复[获取使用jQuery触发事件的元素的ID](http://stackoverflow.com/questions/48239/getting -the-ID-的最元件 - 即烧成-AN-事件使用-jquery的) – undefined

回答

0

此代码打印出来的标识被点击的按钮。

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