I have a jquery function (‘rater’) that I call this way:
<div id="someID"></div>
<script type="text/javascript">
$('#someID').rater({options});
</script>
I want to get the ID (‘someID’ in this case) so then I can use it inside the function as a variable.
Then I use it in something like this:
if (??? == 'someID') { do something }
How can I do it??
Retrieving the selector used to call the plugin:
You can access the selector as a property of the jQuery object.
So, if I called the plugin like this:
Then “div #something” would be alerted.
Retrieving an element’s ID from within a plugin: