Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery菜单栏-语法错误_Jquery_Menubar - Fatal编程技术网

jquery菜单栏-语法错误

jquery菜单栏-语法错误,jquery,menubar,Jquery,Menubar,我有一个jQuery菜单栏,但是外部链接有问题。我不断地得到错误: Syntax error, unrecognized expression: http://google.com 在这里发布文章之后,我更改了var item=$$this.attrref;to var item=$this.attrref;外部联系也起了作用 我继续添加了更多的功能,但之后同样的错误不断出现 有什么想法吗 这是我的密码: <ul id="menu"> <li><a hre

我有一个jQuery菜单栏,但是外部链接有问题。我不断地得到错误:

Syntax error, unrecognized expression: http://google.com
在这里发布文章之后,我更改了var item=$$this.attrref;to var item=$this.attrref;外部联系也起了作用

我继续添加了更多的功能,但之后同样的错误不断出现

有什么想法吗

这是我的密码:

<ul id="menu">
    <li><a href="#home">HOME</a></li>
    <li><a href="#about-us">ABOUT US</a></li>
    <li><a href="http://www.google.com" class="external">EXTERNAL</a></li>
    <li><a href="#contact">CONTACT</a></li>
</ul>
而js:

var lastId,
topMenu = $("#menu"),
topMenuHeight = topMenu.outerHeight()+145,
menuItems = topMenu.find("a"),

scrollItems = menuItems.map(function(){
    var item = $($(this).attr("href"));
    if (item.length) { return item; }
});

$('a.external').click(function() {
    this.target = "_blank";
});

$('a[href*=#]').bind('click', function(e) {
    e.preventDefault();

    var target = $(this).attr("href");

    $('html, body').stop().animate({
        scrollTop: $(target).offset().top 
    }, 3000, function() {

    });
    return false;
});

  $(window).scroll(function(){
   var fromTop = $(this).scrollTop()+topMenuHeight;
   var cur = scrollItems.map(function(){
     if ($(this).offset().top < fromTop)
       return this;
   });

   cur = cur[cur.length-1];
   var id = cur && cur.length ? cur[0].id : "";

   if (lastId !== id) {
       lastId = id;
       menuItems
         .parent().removeClass("active")
         .end().filter("[href=#"+id+"]").parent().addClass("active");
   }                   
  });  


if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {

    $(".footer").css( "position", "relative" );
    $(".contact").css( "marginBottom", "0" );

}
else 
{

  // FadeTo elements
  if ( $(window).width() > 1023) {  

    tiles = $("h2, h3, .grid li, .contact .content .form, .contact .content .contact-text ").fadeTo(0, 0);

    $(window).scroll(function(d,h) {
      tiles.each(function(i) {
          a = $(this).offset().top + $(this).height();
          b = $(window).scrollTop() + $(window).height();
          if (a < b) $(this).fadeTo(1000,1);
      });
    });

  }

}

      $('a.external').click(function() {
      var target = $(this).attr("href");
    this.target = "_blank";
    return false;
});


  //Menu mobile click

  $( ".icon" ).click(function() {
    $( " ul.menu-click" ).slideToggle( "slow", function() {
    // Animation complete.
    });
  });


$(window).load(function(){

$(".preloader").delay(1000).fadeOut("slow")

  // Parallax
  if ($('.parallax-background').length) {
    $(".parallax-background").parallax();
  }

  // Parallax
  if ($('.parallax-background-partners').length) {
    $(".parallax-background-partners").parallax();
  }  

});

我仍然在你的代码中看到这一点。更改此变量项=$$this.attrref;to var item=$this.attrref;。不需要用$包装属性如果我取出它,添加的功能将不起作用-错误是SCRIPT5007:无法获取属性“top”的值:对象为null或未定义的script.js,第38行字符6