I have a php site, and an external js file (where all my js functions are in it) and of course jquery.
At on link I want to call a js
-function and provide this function with two variables, and after the function is finished I want to disable this link (visually).
PHP File
<a href="javascript:void(0);"
class="btn btn-primary btn-lg btn-circle btn-shadow btn-text btn-bookmark"
onclick="bookmark_item( <?=$item_id;?>, <?=$user_id;?> );">
<span class="icon_heart_alt"></span> Save
</a>
JS File
function bookmark_item(item_id, user_id);
$(.btn-bookmark).attr('disabled','disabled');
e.preventDefault();
return false;
});
But instead of having this onclick="..."
phrase in my a
link I want to have a sleek $(document).on('click', 'a', function(){ ... });
function in my js
file. But how is it possible to put a $(this)
selector in my $(document).on...
function? I need this to disable
my a href
button, and I have plenty of them, so hardcoding the ids
or something similar would be really hard to accomplish.