javascript - Loading a background-color for a div when page is loaded -
i wrote simple code i'm trying load background-color div when page loads. here code:
<div id="offerone"> <img src="images/images.jpg" class="img-responsive center-block" alt="img"> </div>
javascript:
<script type="text/javascript"> $('#offerone').attr('style', 'background-color: #f12 !important'); </script>
but isn't loading background-color div when page loads. how can it?
you should put code inside dom ready,
$(function(){ $('#offerone').attr('style', 'background-color: #f12 !important'); })
Comments
Post a Comment