Access JavaScript variable from HTML element attribute
<p>Is there a way to access a JavaScript variable from an attribute from an HTML element?</p>

<p>For example:</p>

<pre><code>&lt;a href="#" id="id1" my-attr="test"&gt;click here&lt;/a&gt;

&lt;script type="text/javascript"&gt;
var test="hello world!";
$("#id1").click(function() { alert($(this).attr('my-attr')) });
&lt;/script&gt;
</code></pre>

<p>What I want to happen is the alert to show "hello world!" but obviously instead it shows "test"</p>

<p>I know I can accomplish this if I use eval(), I was just wondering if there was another way.  Some type of JavaScript reflection or something?</p>

<p>Thanks!</p>
