2012-04-12 47 views
0

我使用下面的代码,的JQuery的onclick功能

function slideonlyone(thechosenone,selectedHeader) { 
    $("#navigation li a").each(function(){ 
     $(this).removeClass("active"); 
     $(selectedHeader).addClass("active"); 
    });  
    $('div[name|="newboxes2"]').each(function (index) {   
     if ($(this).attr("id") == thechosenone) {    
      $(this).slideDown(600); 
      $(this).removeClass("active"); 
      $(this).addClass("active"); 
     } 
     else { 
      $(this).slideUp(600); 
     } 
    }); 
} 
function goToByScroll(id){ 
    $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow'); 
    return false;  
} 
$(document).ready(function(){ 
    $('a.close-btn').click(function() {   
     $('div[name|="newboxes2"]').slideUp(600); 
    });  
}); 

一切工作正常。除了那个。 我的下面的功能工作正常,但第二次点击,我希望它的工作,因为导航链接是点​​击。

function goToByScroll(id){ 
    $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow'); 
    return false;  
} 

谢谢。

+3

哪一个是“一”事件?我不认为你是Neo? – hopla 2012-04-12 13:10:14

+1

您没有任何逻辑来使其在随后的点击中发挥不同的作用,如果这是您想要的。你提到“那个”(nice one,hopla。;-))......你是否尝试过在某个时候使用jQuery的'.one()'?因为这不是你的代码示例中.. – 2012-04-12 13:25:24

+0

我已经添加了不正常的一个.... – Mazhar 2012-04-12 13:32:19

回答

0

jQuery的permite hacer未触发德洛斯EVENTOS .trigger(事件)Y LO coloca EN EL链接apuntando人事件摘要

jQuery的你可以触发与.trigger(事件)事件,调用此链接事件打电话要执行

+0

cesarlarsson,你可以请编辑代码对我来说...... – Mazhar 2012-04-12 14:10:57

+0

喜把完整的代码(用HTML )这里 – cesarlarsson 2012-04-12 14:57:04

+0

你好cesarlarsson是链接进行.... http://www.mannatstudio.com/stackoverflow/index.html,请尽快帮助我。谢谢。 – Mazhar 2012-04-16 06:22:09