我对于这个控制台错误有点头疼,仅在Safari上才可以(实际上是在MacBook上工作)。
我有这个功能:
function exists(element){ var exists = document.querySelector(element); return exists; }
在另一个函数内部调用:
function includeHoverStylesheet(){ var path = $("body").attr("data-hover"); if (!("ontouchstart" in document.documentElement || exists("link[href='" + path + "'"))) { var link = document.createElement("link"); link.rel = "stylesheet", link.href = path, document.head.appendChild(link) && document.body.removeAttribute("data-hover"); } }
现在,在Chrome上像超级按钮一样工作,但是在Safari上,控制台会抛出此错误:
1) Invalid CSS property declaration at: * 2) jQuery.Deferred exception: The string did not match the expected pattern. 3) SyntaxError (DOM Exception 12): The string did not match the expected pattern.
有人知道发生了什么事吗???
在此先感谢大家!
缺少右括号,因此您使用的是无效的选择器。(正如Roamer-1888提到的那样)
在以下讨论中测试了不同浏览器中的无效选择器的讨论中,只有Safari才带来严格的错误提示:https : //www.reddit.com/r/firefox/comments/5nbmqi/on_handling_invalid_selector_strings/
对于所有jquery用户:请检查您的jquery版本,因为选择器问题已修正。
我仅在Safari上有此错误
var div = $('');声明在Firefox和Chrome上正常运行,但在使用jquery 1.11.1版本时在Safari上无效;但是使用jquery 1.12.4在所有这些程序中都能正常工作。
就我而言,我使用以下语法解决了该问题:
var div = $('', {"class":"abc"});推荐阅读
如何解决《RabbitMQdef回调(通道,方法,属性,主体)》经验,为你挑选了1个好方法。 ... [详细] 如何解决《为什么Nodefs.writeFile()方法成功,但是一个空文件然后被发送到浏览器?》经验,为你挑选了1个好方法。 ... [详细] 如何解决《为什么css"text-decoration"继承不适用于"inline-block"?》经验,为你挑选了1个好方法。 ... [详细] 如何解决《PowerShell是否编译脚本?》经验,为你挑选了1个好方法。 ... [详细] 如何解决《SpringJpaRepository如何查询@ManyToMany实体》经验,为你挑选了1个好方法。 ... [详细] 如何解决《基于两个标准从列表中检索项目的"最佳"pythonic方法》经验,为你挑选了1个好方法。 ... [详细] 如何解决《批处理文件:检查是否存在带有模式的文件》经验,为你挑选了2个好方法。 ... [详细] 如何解决《AWSDataPipelineRedShift"未找到分隔符"错误》经验,为你挑选了1个好方法。 ... [详细] 如何解决《VBA:将VariableArray转换为String》经验,为你挑选了2个好方法。 ... [详细] 如何解决《为什么Xcode7.2崩溃'无法实例化名为IBNSLayoutConstraint的类'?》经验,为你挑选了2个好方法。 ... [详细] 如何解决《INT0x13/AH=0x02适用于软盘映像,但不能在闪存驱动器上刻录》经验,为你挑选了1个好方法。 ... [详细] 如何解决《如何自动更新所有Node.js模块?》经验,为你挑选了1个好方法。 ... [详细] 如何解决《编译ISOSQL-2003ANTLR语法》经验,为你挑选了0个好方法。 ... [详细] 如何解决《如何停止ScheduledExecutorService?》经验,为你挑选了1个好方法。 ... [详细] 如何解决《创建Hive表以从镶木地板/avro模式中读取镶木地板文件》经验,为你挑选了1个好方法。 ... [详细] 如何解决《Openlayer3-检查功能是否在范围的范围内》经验,为你挑选了1个好方法。 ... [详细] 如何解决《如何使用PHP在Office365中获取刷新令牌和访问令牌》经验,为你挑选了1个好方法。 ... [详细] 如何解决《chrome.storage.managed在我的信息亭应用中似乎无法正常运行》经验,为你挑选了0个好方法。 ... [详细] 如何解决《围绕特定树枝变量{{product.name}}包装上下文html》经验,为你挑选了0个好方法。 ... [详细] 如何解决《如何在开发过程中从一个地方的不同线程中捕获所有未捕获的异常?》经验,为你挑选了1个好方法。 ... [详细]吐了个 "CAO" !RankList | 热门文章
- 1crm 2011 OP:运行什么服务器的插件?
- 2微软Band 2上的UWP
- 3限制方法中泛型类型的目的是什么?
- 4默认导出后的分号
- 5Delphi - 以零为单位递增整数
- 6OutputStreamWriter.append不将文本附加到Android编程的文本文件中
- 7Java自动装箱和数学表达式?
- 8在C/C++中,ZERO左移还是右移实际生成指令?
- 9UIRectCornerTopRight的圆角不起作用
- 10为什么lodash的.isObject,.isPlainObject的行为与"typeof x ==='object'"不同?
- 11连接表的索引
- 12如何删除tumblr控件/按钮/ iframe?
- 13包装BCD到DPD:如何改进这个amd64装配程序?
- 14为什么使用这个全局`operator <<`无法编译?
- 15为什么requestIdToken返回null?
- 16OpenWRT:无法安装软件包 - 内存问题
- 17是否可以将事件侦听器绑定到外部脚本的阴影dom中的元素?
- 18升级到react-native 0.16错误
- 19TensorFlow检查点保存并读取
- 20在同一个StringBuilder实例上调用toString时输出不同
DevBox开发工具箱 | 专业的在线开发工具网站 京公网安备 11010802040832号 | 京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有