I have a jquery script that changes the image of an element on hover, and the problem is that it does not preload the images. I know that the code is a little crappy (good, good, true, crappy), but I have to work with it, so ..
<script type="text/javascript"> $(document).ready(function() { $('#searchbox_submit') .mouseover(function() { var src = $('.searchbox_submit').css("background-image",'url("/wp-content/themes/Locator/images/search_over.png")'); $('.searchbox_submit').attr("src", src); }) .mouseout(function() { var src = $('.searchbox_submit').css("background-image",'url("/wp-content/themes/Locator/images/search.png")'); $('.searchbox_submit').attr("src", src); }); $('#bribe_submit') .mouseover(function() { var src = $('.bribe_submit_img').attr("src").replace(".png","_over.png"); $('.bribe_submit_img').attr("src", src); }) .mouseout(function() { var src = $('.bribe_submit_img').attr("src").replace("_over.png",".png"); $('.bribe_submit_img').attr("src", src); }); ///////////////////////////////////////////////////////////////////////searchbox $('#searchbox_submit').click(function() { //,{onAfter:function(){ alert('tests'); } } //load_list($(this).parents('form').serializeArray()); codeAddress(); }); $("#search_butt").keypress(function(event) { //load_list($(this).parents('form').serializeArray()); if ( event.which == 13 ) { //load_list($(this).parents('form').serializeArray()); codeAddress(); event.preventDefault(); } }); }); </script>
and conclusion:
<form> <input id="search_butt" class="i" type="text" value="Set your location: country, city" style="font-style:italic;" onblur="if(this.value=='') this.value='Set your location: country, city';" onfocus="if(this.value=='Set your location: country, city') this.value='';" name="s"> <span id="searchbox_submit" class="searchbox_submit"/> </form>
is there an easy way without changing integer script?
Ps sorry for bad english :)
source share