jQuery的语法错误:#​​/ [英] jQuery syntax error: #/

查看:116
本文介绍了jQuery的语法错误:#​​/的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用jQuery,Twitter的引导和AngularJS为我的Web应用程序。我一直在努力做路由,但jQuery的一直给我语法错误,无法识别的前pression:#/时间每当我尝试点击时间选项卡上,或相反亦然。我不知道这是造成这个错误,但它是由#号引起的。我曾广泛,但无济于事一派。这里是我的code:

I am currently using jQuery, Twitter Bootstrap and AngularJS for my web application. I've been trying to do routing, but jQuery keeps giving me Syntax error, unrecognized expression: #/time whenever I try to click on the time tab, or vice versa. I have no idea which is causing this error, except that it is caused by the # sign. I have googled extensively but to no avail. Here is my code:

<ul class="nav nav-tabs">
  <li class="active">
    <a href="#/main" data-toggle="tab" id="main-tab">Main</a>
  </li>
  <li>
    <a href="#/time" data-toggle="tab" id="time-tab">Time Reports</a>
  </li>
</ul>

我需要保持斜线,因为我用它为我的AngularJS路由(即的index.html#/主的index.html#/时间将加载在我的div的一个不同的内容)。
怎么可能会导致这个错误?

I need to keep the slash as I use it for my AngularJS routing (i.e. index.html#/main and index.html#/time will load different content in one of my divs). What could possibly be causing this error?

推荐答案

我想在的href额外的斜线指定 ID 的目标。删除它们,它应该工作正常。

I guess extra slash in the href specifying id of the target. remove them and it should work fine.

<ul class="nav nav-tabs">
  <li class="active">
    <a href="#main" data-toggle="tab" id="main-tab">Main</a>
  </li>
  <li>
    <a href="#time" data-toggle="tab" id="time-tab">Time Reports</a>
  </li>
</ul>

引导看着href值作为目标元素的ID显示为选项卡的内容。所以这里在这种情况下,要寻找一些与ID = #/时间不存在。

如果你想保持完整的href您可以使用数据目标属性。

if you want to keep href intact you can use data-target attribute

<a href="#/main" data-toggle="tab" data-target="#main" id="main-tab">Main</a>

这篇关于jQuery的语法错误:#​​/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆