Trying to toggle between two images when clicking on a heading. For starters, I haven't even been able to get them to show. Any ideas?
<h2 class="expand" id="content-1" style="cursor:pointer;" value="One">Click to expand One</h2>
<h2 class="expand" id="content-2" style="cursor:pointer;" value="Two">Click to expand Two</h2>
Tried below but nothing so far.
$('.expand').on('click', function() {
if($(this).text().indexOf('expand') >0 )
$(this).text('Click to collapse ' + $(this).attr("value"));
$('.expand').css('background-image', 'url(' + img/arrow-up.gif + ')');
else
$(this).text('Click to expand ' + $(this).attr("value"));
$('.expand').css('background-image', 'url(' + img/down-up.gif + ')');
});
and
$(this).text('Click to collapse ' + $(this).attr("value") + $(this).css...);
(' + img/arrow-up.gif + ')is correct? @DA fixed