當我點擊一個產品時,我需要添加一個類:focus
,因此在加載下一頁之前,您可以看到一個藍色的矩形。爲什麼jQuery僅在加載停止時加載?
我已經添加了一個jQuery來做到這一點,所以當你點擊一個產品它會改變這個類,並添加一個帶有陰影的新類。
但它只適用於桌面而不適用於移動設備。
$(document).ready(function() {
$('div.product-container').on('click', function() {
$(this).addClass('aftertap');
});
});
.aftertap {
-webkit-box-shadow: 0px 0px 12px 3px rgba(113, 129, 194, 1) !important;
-moz-box-shadow: 0px 0px 12px 3px rgba(113, 129, 194, 1) !important;
box-shadow: 0px 0px 12px 3px rgba(113, 129, 194, 1) !important;
}
<div class="product-container style1 clearfix" itemscope="" itemtype="http://schema.org/Product">
<div class="left-block">
<div class="product-image-container">
<a class="product_img_link" href="http://localhost/prestawebserver/forward/102-cropped-leggings-performance-cotton.html" title="Cropped Leggings - Performance Cotton" itemprop="url">
<img class=" img-responsive" src="http://localhost/prestawebserver/1065-home_default/cropped-leggings-performance-cotton.jpg" alt="cropped-leggings-performance-cotton" title="cropped-leggings-performance-cotton" itemprop="image">
</a>
</div>
</div>
DOM已經加載。您滾動查看產品,所以您點擊其中一個,並且應該加載Javascript ..(該DOM已經加載) 僅適用於移動版本。桌面版本沒問題 –
或者您可以在關閉主體標籤之前將腳本放置在文檔的底部。 – Aziz
它的工作。你在期待什麼? – Pugazh