Javascript 函数jquery中的函数

Javascript 函数jquery中的函数,javascript,jquery,twitter-bootstrap-3,Javascript,Jquery,Twitter Bootstrap 3,我需要在一次点击事件中运行两个函数,但我不知道如何嵌套它们 当前,如果单独运行,但不能同时运行,这两种方法都可以工作 此功能在单击后关闭我的菜单 $(document).on('click','.navbar-collapse.in',function(e) { if( $(e.target).is('a') ) { $(this).collapse('toggle'); } }); 这个函数会滚动到我的特定锚点 function scrollToAnchor() {

我需要在一次点击事件中运行两个函数,但我不知道如何嵌套它们

当前,如果单独运行,但不能同时运行,这两种方法都可以工作

此功能在单击后关闭我的菜单

$(document).on('click','.navbar-collapse.in',function(e) {
  if( $(e.target).is('a') ) {
    $(this).collapse('toggle');     
  }
});
这个函数会滚动到我的特定锚点

function scrollToAnchor() {
  if($(".jquery-anchor").length > 0 && document.URL.indexOf("#") >= 0){  
    var anchor = document.URL.split("#")[1];
    $(".jquery-anchor").each(function() {
      if($(this).attr("name") == anchor) {
        $("html,body").animate({
          scrollTop: $(this).offset().top - 50},
          'slow');
      }
    });     
  }
}


$(function() {
  $("a[href*='#JDG']:not([href='#'])").click(function() { 
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
      && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        $('html,body').animate({
          scrollTop: target.offset().top - 30 //offsets for fixed header
        }, 1000);
        return false;
      }
    }
  });

  //Executed on page load with URL containing an anchor tag.
  if($(location.href.split("#")[1])) {
    var target = $('#'+location.href.split("#")[1]);
    if (target.length) {
      $('html,body').animate({
        scrollTop: target.offset().top - 30 //offset height of header here too.
      }, 1000);
      return false;
    }
  }
});
我不知道如何在下面的click事件中以及在何处放置top函数。这是可能的,对吗

$("a[href*='#JDG']:not([href='#'])").click(function() { 
});

从两个函数中删除
return false

从两个函数中删除
return false

+1您想解释为什么为了他人的利益@JasperSeinhorst?返回false将阻止其他处理程序执行+1您想解释为什么为了他人的利益@JasperSeinhorst?返回false将阻止其他处理程序执行执行