我对于这个控制台错误有点头疼,仅在Safari上才可以(实际上是在MacBook上工作).
I've a little headache with this console error, ONLY on Safari (working on MacBook actually).
我有这个功能:
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上,控制台会抛出此错误:
Now, on Chrome works like a charm, but on Safari the console throw this error:
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.有人知道发生了什么事吗?
Someone have idea what hell happening???
先谢谢大家!
推荐答案缺少右括号,因此您使用的是无效的选择器. (正如Roamer-1888在评论中提到的那样)
There is a closing bracket missing, so you are using an invalid selector. (as Roamer-1888 mentioned as comment)
在以下讨论中测试了不同浏览器中的无效选择器的情况下,只有Safari才提出严格的错误提示: www.reddit/r/firefox/comments/5nbmqi/on_handling_invalid_selector_strings/
Having a look at the following discussion where invalid selectors in different browsers has been tested, only Safari is that strict bringing up errors: www.reddit/r/firefox/comments/5nbmqi/on_handling_invalid_selector_strings/
对于所有jquery用户:,因为选择器问题已修正,请检查您的jquery版本.
For all jquery-Users: check your jquery version, as there has been bugfixes on selector issues.
在此声明中,我在Safari上只有 错误
I had the same error only on Safari on this statement
var div = $('<div class="abc">');使用jquery 1.11.1版本时,该语句在Firefox和Chrome上运行良好,但在Safari上运行不正常;但是使用jquery 1.12.4可以很好地解决所有问题.
A statement working fine on Firefox and Chrome, but not on Safari when using version jquery 1.11.1; but working fine in all of them with jquery 1.12.4.
就我而言,我使用以下语法解决了该问题:
In my case I solved it using the following syntax:
var div = $('<div>', {"class":"abc"});更多推荐
jQuery.Deferred异常:字符串与预期的模式不匹配
发布评论