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

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -