我从这行代码中得到了这个错误
$( 'path.div-clickable' ).each(function( index ) {
$( this ).addClass( 'polygon'+index );
});
抛出错误:
Uncaught Error: Syntax error, unrecognized expression: #
at Function.Sizzle.error (jquery.js:1586)
at Sizzle.tokenize (jquery.js:2238)
at Sizzle.select (jquery.js:2665)
at Function.Sizzle [as find] (jquery.js:890)
at jQuery.fn.init.find (jquery.js:2921)
at jQuery.fn.init (jquery.js:3031)
at jQuery (jquery.js:98)
at c (bootstrap.min.js:7)
at HTMLAnchorElement.<anonymous> (bootstrap.min.js:7)
at Function.each (jquery.js:368)
在ajax请求中调用此函数。
$.getJSON("http://www.example.com/api/v2/sql?format=GeoJSON&q=" +
"SELECT * FROM example", function(data) {
addClassToPath();
});
很奇怪,代码运行正常。