vendredi 3 avril 2015

random background image not loading

I am trying to activate the random background image for the "something" element, but without success, can anyone give a suggestion what I am doing wrong ? This is from the content-single-product.phpWoocommerce plugin



<div class="item-layout" id="something">
<script type="text/javascript">
var images = [
"http://ift.tt/1Du9udu",
"http://ift.tt/19O7Fdj",
"http://ift.tt/1Du9udw",
"http://ift.tt/1Du9utK"
];

$("#something").css("background", "url(" + images[Math.floor(Math.random() * images.length)] + ")");
</script>
<div itemscope itemtype="http://ift.tt/GXPmjp" 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(); ?> -->


The css for #something is width:100%; height:400px;





Aucun commentaire:

Enregistrer un commentaire