2012-04-12 44 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