1
我有一大堆的安排如下A-鏈接,一個:沒有[^ HREF =「...‘(’不開始」運營商)不工作
div class="thumbnail_wrap">
<a href="photos/2014/1.png">..</a>
<a href="photos/2014/2.png">..</a>
<a href="photos/2015/1.png">..</a>
<a href="photos/2016/1.png">..</a>
..
</div>
,我需要選擇所有對應於某個鏈接一年中所含var year
alert('Year selected: ' + year + ' ' +
'Photos in this section: ' +
$('.thumbnail_wrap > a[href^="photos/' + year + '"]').length + ' ' +
'Photos NOT in this section: ' +
$('.thumbnail_wrap > a:not[href^="photos/' + year + '"]').length );
// Find all images with the "/photos/<YEAR>" URL and make them visible
$('.thumbnail_wrap > a[href^="photos/' + year + '"]').show();
// Find all images with the wrong Year URL and make them hidden
$('.thumbnail_wrap > a:not[href^="photos/' + year + '"]').hide();
第一個表達式總是工作。但a:not
表達式不起作用。收到此錯誤,
TypeError: a is undefined jquery-1.10.2.js
'$(」 thumbnail_wrap> A:不使用(HREF^= 「照片/ '+年+'」] )')。hide();' – Manav
Got it thx missing paren –