2013-07-04 39 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); 
})