i've got some jquery script that changes element image on mouseover and the problem is it doesn't preload images.. I know the code is crappy a little (ok, ok really 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 output:
<form>
<!--<input type="text" class="searchbox" name="s" value="" />-->
<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 any easy way without changing whole script?
P.s. sorry for bad english :)