1
我得到一個可愛的語法錯誤。這是當我嘗試選擇所有沒有包含佔位符URL的href的錨標記時,即href="#"
。jQuery:不選擇符和哈希符號語法錯誤
我已經試過如下:
$("a:not(href='#')");
//swapped single with double quotes
$('a:not(href="#")');
// no quotes at all
$("a:not(href=#)");
// wildcard selector
$("a:not(href*=#)");
,他們都導致以下錯誤:
Uncaught Error: Syntax error, unrecognized expression: href=#(…)
任何想法?
摘錄如下:
var $item = $("a:not(href='#')");
console.log($item);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="http://google.com">Selected</a>
<a href="#">Not selected</a>
@Vohuman我做了。我只是忽略了它。 – evolutionxbox