Klapsius Klapsius - 16 days ago 5
jQuery Question

Jquery run onClick function as separate function

I have a

jquery
onClick
function:

$('body').on('click', '#id_name', function() {
...


and i would like to execute this function as another function on ajax call (currently this is only
onclick
).

if my
ajax
call is success then:

success: function() {
// then execute top function
}


is it possible to do that?

Answer

Then you can use $('#id_name').trigger('click') in the ajax success callback.