window.location.hash上的错误

巴乔什

我有Rails应用程序,在这里我修改了一些文件,然后运行bundle instal和asset:precompile。

之后,我在文件至极的错误没有更改。发生错误的文件部分:

<script type="text/javascript">
function openCurrentTab() {
var hash = window.location.hash || '#info'
$('a[href=' + hash + ']').tab('show')
}

$(function() {
openCurrentTab()

$('#outage-tabs > li > a').click(function(evt) {
  evt.preventDefault()
  $(this).tab('show')
  history.pushState(null, null, this.hash)
})
})
window.onpopstate = openCurrentTab
</script>

错误(在控制台中)

application-76c7fea….js:24 Uncaught Error: Syntax error, unrecognized    expression: a[href=#info]

谢谢你的帮助

瓦迪姆

似乎您的jQuery搜索有错误

$('a[href=' + hash + ']').tab('show')

使用结尾选择器和下一个语法:请勿在词条内使用#,而应使用''来设置搜索词

$("a[href$='hash-without-#-symbol']")

https://api.jquery.com/attribute-ends-with-selector/

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

JavaScript分割window.location.hash

window.location.href上的onchange事件

“ window.location.href”和“ window.location.hash”之间有什么区别?

window.location.hash 和 location.hash 有什么区别?

Javascript 使用 .hash 重定向 window.location.url

开启-window.location.hash-更改了吗?

window.location.hash始终显示为空

试图将变量传递给window.location.hash

百里香上的window.location.href

在Android浏览器上window.location失败

WebSQL:无法在更改window.location上创建表

JavaScipt window.location

window.open与window.location.href

如何在不跳文档的情况下更新window.location.hash?

Javascript无需滚动即可更改window.location.hash,但仍会触发CSS:target伪类

Asp Core 5.0 Razor Page:如何在调用 RedirectToPage() 时保留 window.location.hash

替换 window.location.hash url 中的一个字符

jQuery:如何自动将window.location.hash应用于与按钮id中相同的数字?

window.location.hash-它是什么,以及它的用例?

jQuery:根据window.location.hash将DIV类分配为“活动”类

如何将字符串添加到 window.location.hash

window.location与仅位置

Window.location文件下载

Javascript / Jquery window.location

动画后的window.location

window.location.href = window.location.href和window.location.reload()之间的区别

window.location.href上的第二个参数在Controller上为NULL

$ window.location.origin使用IE时给出错误的值

更改“ Window.location.href”时,将删除“窗口”对象上存储的属性