0

I'm dealing with the following javascript function:

function getId() {
    var retval;

    $(document).on('click', '#dlt', function () {
    retval = $(this).closest('tr').find('td:first').html();
        alert("Here the retval is: " + retval);
    });

    alert(retval);
    return retval;
}

I would like to return retval value - it is later used in ajax url to delete some data.

On launch I'm getting following alerts:

1) "Undefined" 2) "Here the retval is 53"

So apparently the function is working (desired number 53 is correct), but I dont understand why the function is returning "undefined". I tried to declare the retval variable globaly, but it didn't work.

Anybody can help me with this? Thanks in advance

xcelm
  • 541
  • 1
  • 6
  • 19

0 Answers0