English 中文(简体)
j Query 点击活动,没有在 j木板上工作
原标题:jQuery click event not working in a jQuery tab page

在我的MVC3解决方案中,我用一个 j子。 问题在于,当我将这些表格之一插入一个环节时,我无法控制这一联系。

我的守则是:

主要表格子:

<div id="tabContainer">
<ul>
    <li>@Html.ActionLink("Tab 1", "DetailFooterTab1", "MyController")</li>
    <li>@Html.ActionLink("Tab 2", "DetailFooterTab2", "MyController")</li>
    <li>@Html.ActionLink("Tab 3", "DetailFooterTab3", "MyController")</li>
</ul>

$("#tabContainer").tabs();

我的塔布3页有这一编号:

<a href="#" id="buttonTest">Test</a>

<script type="text/jscript">

$("#buttonTest").click(function () {
    alert( I am a link in the Tab 3 page );
});

</script>

这些 j木制成物。 我可以点击其中之一,该系统正在显示相应的表格(并隐藏其他表格内容)。 BUT 当我点击试验链路时,没有发生任何事情! 任何想法?

最佳回答

你把你的法典放在美元(文件)上。 准备就绪?

$(document).ready(function(){
   $("#buttonTest").click(function () {
     alert( I am a link in the Tab 3 page );
   });
});

or if that element added on dom later. you can use live event like

$("#buttonTeest").live( click ,funciton(){
    alert( I am a link in the Tab 3 page );
});
问题回答

为此,

$("#buttonTest").click(function (e) {
    e.preventDefault();
    alert( I am a link in the Tab 3 page );
});

如果你在临时使用时添加这些物品,就会生活,而不是约束。

$( #buttonTest ).live( click , function() {
e.preventDefault();
    alert( I am a link in the Tab 3 page );
});




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!