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

javascript - Can Piwik report referrer in real time? -

asp.net - Google Drive Access: At least one client secrets (Installed or Web) should be set -

excel vba add hyperlink to shape in group -