0
我想激活隨機背景圖像的「東西」元素,但沒有成功,任何人都可以給我一個建議我做錯了什麼? 這是從content-single-product.php
Woocommerce插件隨機背景圖像不加載
<div class="item-layout" id="something">
<script type="text/javascript">
var images = [
"http://domainname.com/image-12.jpg",
"http://domainname.com/image-11.jpg",
"http://domainname.com/image-13.jpg",
"http://domainname.com/image-14.jpg"
];
$("#something").css("background", "url(" + images[Math.floor(Math.random() * images.length)] + ")");
</script>
<div itemscope itemtype="http://schema.org/Product" id="product-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php ...
?>
<div class="summary">
<?php ... ?>
</div>
</div>
</div>
<div style="clear:both;"></div>
<?php
...
?>
<?php do_action('woocommerce_after_single_product'); // upsell ?>
</div><!-- #product-<?php the_ID(); ?> -->
爲#something is width:100%; height:400px;