forum

Home / DeveloperSection / Forums / Access Asp.net control using $(this) within setTimeout()

Access Asp.net control using $(this) within setTimeout()

Anonymous User 2308 10-Nov-2014

I have a list of HTML controls and I need to bind a listener for the keyup event to each of these. Once that is triggered, some other actions should subsequently be kicked off after a time delay. I'm using setTimeout for that.

$(".TextBoxClass").each(function () {
  $(this).keyup(function () {
    alert("Id = " + $(this));   
    setTimeout(function () {
       alert("current Id = " + $(this))
    }, 50);
  })
})

The first alert message shows the correct id of the control which triggers the keyup event. The second alert within the setTimeout says current id = [object][object].

How can I access the control within the setTimeout callback function?


Updated on 11-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By