jquery - Toggle a background images position -


this question has answer here:

i have below code show/hides div whilst changing text depending on whether div displayed or not:

$('#more').click(function() {     $('#extra').slidetoggle('fast');     $('#more').text(function(_,txt) {         return txt == 'more us' ? 'less us' : 'more us';     });     return false; }); 

on #more link have arrow pointing down (for 'more us' text, when div hidden) i'd change arrow point when div visible , text reads 'less us'. how can edit above code this?

try

$('#more').click(function() {     $('#extra').slidetoggle('fast');     $('#more').text(function(_,txt) {         var ret='';          if ( txt == 'more us' ) {            ret = 'less us';            $(this).css('background','url(link/to/image1.png)');         }else{            ret = 'more us';            $(this).css('background','url(link/to/image2.png)');         }         return ret;     });     return false; }); 

courtesy

toggle text when link clicked


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -