Reputation: 543
I'm trying to toggle a attr value (rel or href) on click.
$('#open').click(function () {
$(this).text($(this).text() == 'View Project' ? 'Close' : 'View Project');
$(this).attr('rel','#page');
$('#view').slideToggle(550);
return false;
});
I've got a text swap in there that's change out the text for a#open when toggled open/toggle close.
But I need to swap the rel or href from #view to #page when toggled open but then back to #view on the toggle close. I'm needing the swap of these as it's needed for using scrollTop.
Any help would be greatly appreciated!
Upvotes: 2
Views: 6286
Reputation: 2118
Basically you're wanting to do the same thing to your rel attribute that you're doing to the text of the element.
$(this).attr('rel',$(this).attr('rel') == '#page' ? '#open' : '#page');
and I assume you want to use the current rel for the slide toggle
$($(this).attr('rel')).slideToggle(550);
Upvotes: 3
Reputation: 6283
not sure I understand completely, but have you considered using .toggle()
in jquery in place of .click()
and then use different functions
Upvotes: 0