Reputation: 1111
In jQuery, how do I extract the number 4 from the doThisThing() function call from an onclick event:
<div id="div1" onclick="doThisThing(4)"></div>
and how do I set it?
Thanks.
Upvotes: 1
Views: 247
Reputation: 1655
Is this what you mean? And why do you need to set it, too? Maybe you could explain what you're trying to do so we can better help you.
$(document).ready(function() {
$('#div1').attr('onclick', 'doThisThing(4)');
});
Upvotes: 1
Reputation: 85126
Once you are in the function itself you will have access to it:
function doThisTHing(inputValue)
{
alert(inputValue);
}
How you set what gets passed depends on what you are trying to pass.
Upvotes: 0