Possible Duplicate:
Is there a way to access a javascript variable using a string that contains the name of the variable?
I have some content scripted to show based on a user's interaction with my prototype. When they click on a certain callout I'm trying to use the rel
tag associated with it to feed in the correct variable, but so far I've had no luck.
Here's a small example.
<div class='cool-btn' rel='awesome'>
Content here
</div>
and then
var awesome = 'some content';
$('.cool-btn').click(function() {
//do stuff
$('.other-selector').append($(this).attr('rel'));
}
I remember that when you were jumping in and out of variables and selectors in ActionScript (flashback!) you would throw things in brackets []
, but I've been unsuccessful in attempting similar things here or finding information regarding that.
Thanks for any assistance-