I'm working on separating JavaScript code from my HTML. I currently have code that looks like this:
<div onclick="return do_something_with('100566');" class="clickable">Click Me!</div>
I'd like to swap the onclick to an attribute containing just the parameter I'm passing to the method.
I'm using jQuery for this with the following type of code:
var $j = jQuery;
$j(function(){
$j('.clickable').live('click',function(){
param = $j(this).attr('attribute_name');
do_something(param);
});
});
What attribute can I use for 'attribute_name' that would be safe for communicating this parameter value? I know I can use id, but I would have already defined an element with the same id in a different place in the DOM.
Any suggestions?