jQuery click 事件触发两次,页面有多个母版页
jQuery click event fires twice, page has multiple master pages
我有一个包含嵌套母版页的页面。触发两次的控件位于母版页 (BasicContentMaster) 上,还有 jquery 单击事件函数。如何防止两次触发控件的点击事件?
继承两个母版页的页面(先继承LandingPageMaster),
<%@ Page Title="" Language="vb" AutoEventWireup="false"
MasterPageFile="~/landingpages/LandingPageMaster.master" CodeBehind="Components.aspx.vb" Inherits="WebsiteProject.Components" %>
然后LandingPageMaster继承BasicContentMaster页面
<%@ Master Language="VB" MasterPageFile="~/BasicContent.Master" AutoEventWireup="false" CodeBehind="LandingPageMaster.master.vb" Inherits="WebSiteProject.LandingPageMaster" %>
BasicContentMaster 中的此处是从组件页面单击时触发两次的控件,
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="BasicContent.master.vb" Inherits="WebSiteProject.BasicContent" %>
<img id="m-navigation-img" src="/images/nav_menu.png" />
jquery点击功能
$('#m-navigation-img').click(function () {
$('#m-navigation').slideToggle();
});
试试这个:
$('#m-navigation-img').unbind('click').bind('click', function () {
$('#m-navigation').slideToggle();
});
我有一个包含嵌套母版页的页面。触发两次的控件位于母版页 (BasicContentMaster) 上,还有 jquery 单击事件函数。如何防止两次触发控件的点击事件?
继承两个母版页的页面(先继承LandingPageMaster),
<%@ Page Title="" Language="vb" AutoEventWireup="false"
MasterPageFile="~/landingpages/LandingPageMaster.master" CodeBehind="Components.aspx.vb" Inherits="WebsiteProject.Components" %>
然后LandingPageMaster继承BasicContentMaster页面
<%@ Master Language="VB" MasterPageFile="~/BasicContent.Master" AutoEventWireup="false" CodeBehind="LandingPageMaster.master.vb" Inherits="WebSiteProject.LandingPageMaster" %>
BasicContentMaster 中的此处是从组件页面单击时触发两次的控件,
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="BasicContent.master.vb" Inherits="WebSiteProject.BasicContent" %>
<img id="m-navigation-img" src="/images/nav_menu.png" />
jquery点击功能
$('#m-navigation-img').click(function () {
$('#m-navigation').slideToggle();
});
试试这个:
$('#m-navigation-img').unbind('click').bind('click', function () {
$('#m-navigation').slideToggle();
});