How to access the asp control using $(this) within the setTimeout() function

Gowthaman

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?

Oleksandr T.
  <div id="controls">
    <input class="TextBoxClass" type="text" value="1" id="id-1">
    <input class="TextBoxClass" type="text" value="2" id="id-2">
    <input class="TextBoxClass" type="text" value="3" id="id-3">
    <input class="TextBoxClass" type="text" value="4" id="id-4">
    <input class="TextBoxClass" type="text" value="5" id="id-5">
  </div>


$('#controls').on('keyup', '.TextBoxClass', function () {
  var $this = $(this);

  setTimeout(function(){ 
    // alert("current value = " + $this.val()); 
    alert("current element id = " + $this.attr('id')); 
  }, 50);
});

http://jsbin.com/yisore/1/

http://jsbin.com/yisore/1/edit

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to access the asp control using $(this) within the setTimeout() function

From Dev

how to access the control within a control in tablelayout

From Dev

How to access a global service function within a twig extension using Symfony?

From Dev

How to access a private variables using a common public function within the constructor

From Dev

How to access to a native control within a DependencyService?

From Dev

How to control(access) the streams of TcpClients within the threads

From Dev

How to access an array within a function?

From Dev

Access ASP.NET control using javascript

From Dev

addClass not working within setTimeout function

From Dev

How to Call/access control combobox asp devexpress

From Dev

How to access var within function but outside subfunction

From Dev

How access to variables within an anonymous function?

From Dev

How to access callback arguments within another function?

From Dev

How to access a key value within State in a function?

From Dev

how to access a control within Data Template from code behind?

From Dev

How to access all vertexes within the same patch in Tessellation Control Shader

From Dev

How can I access $(this) in my hover function with setTimeout

From Dev

unable to access function from another function using this within same object

From Dev

Is there a way to access control properties within custom user control from Designer using c# (Windows Forms)

From Dev

How control access to specific folder using .htaccess?

From Dev

How control access to specific folder using .htaccess?

From Dev

How to using XAML to access named control in template

From Dev

How to access the property function within a function object javascript

From Dev

How to call a predefined function and access the properties of a variable that is within that function?

From Dev

Access variable within function

From Dev

Access variable within function

From Dev

What is exactly happening when I am using setTimeout within another function and trying to print the value of the argument passed?

From Dev

How to access values within object within array within object within array using jQuery $.each?

From Dev

VBA Excel - How to Access Control within Frame within Worksheet? Refactor / Optimize

Related Related

  1. 1

    How to access the asp control using $(this) within the setTimeout() function

  2. 2

    how to access the control within a control in tablelayout

  3. 3

    How to access a global service function within a twig extension using Symfony?

  4. 4

    How to access a private variables using a common public function within the constructor

  5. 5

    How to access to a native control within a DependencyService?

  6. 6

    How to control(access) the streams of TcpClients within the threads

  7. 7

    How to access an array within a function?

  8. 8

    Access ASP.NET control using javascript

  9. 9

    addClass not working within setTimeout function

  10. 10

    How to Call/access control combobox asp devexpress

  11. 11

    How to access var within function but outside subfunction

  12. 12

    How access to variables within an anonymous function?

  13. 13

    How to access callback arguments within another function?

  14. 14

    How to access a key value within State in a function?

  15. 15

    how to access a control within Data Template from code behind?

  16. 16

    How to access all vertexes within the same patch in Tessellation Control Shader

  17. 17

    How can I access $(this) in my hover function with setTimeout

  18. 18

    unable to access function from another function using this within same object

  19. 19

    Is there a way to access control properties within custom user control from Designer using c# (Windows Forms)

  20. 20

    How control access to specific folder using .htaccess?

  21. 21

    How control access to specific folder using .htaccess?

  22. 22

    How to using XAML to access named control in template

  23. 23

    How to access the property function within a function object javascript

  24. 24

    How to call a predefined function and access the properties of a variable that is within that function?

  25. 25

    Access variable within function

  26. 26

    Access variable within function

  27. 27

    What is exactly happening when I am using setTimeout within another function and trying to print the value of the argument passed?

  28. 28

    How to access values within object within array within object within array using jQuery $.each?

  29. 29

    VBA Excel - How to Access Control within Frame within Worksheet? Refactor / Optimize

HotTag

Archive