Swap Background image with jQuery
I am currently finishing off a jQuery slide that enables the user to click
a div and then a div slides down. But what I wish to do is to change the
background image of div.slide while it's down, so I have an up arrow and
then a down arrow for each state.
I currently have:
<script type="text/javascript">
$("div.slide").click(function(){
$(".tst").slideToggle( 'slow', function(){ });
});
</script>
Please bare with me as I am VERY new to jQuery, but so far I have whats
above and feel like I'm not too far away from the rest, but I cannot seem
to work out how to change the background?
Any direction/links or help is appreciated.
New Edit of code:
<script type="text/javascript">
$('.tst').hide();
$("div.slide").click(function(){
$("div.slide").css('background-image',
'url("http://universitycompare.com/wp-content/themes/blue-and-grey/images/upward_arrow.jpg")');
$(".tst").slideToggle( 'slow', function(){
});
});
</script>
No comments:
Post a Comment