<input type="text" value="" onkeyup="new Create_table().add_str()" /> function Create_table() { this.add_str = function () { //как здесь получить доступ к input } } 

This is not suitable for me

 onkeyup="new Create_table().add_str(this)" this.add_str=function(self){} 
  • 2
    So: <input type = "text" value = "" onkeyup = "new Create_table (this) .add_str ()" /> function Create_table (element) {var el = element; this.add_str = function () {// how to access input el // here it is}} - Specter
  • heheh why not? - thunder
  • Specter did not help, but thanks. - koza4ok

2 answers 2

but also like this:

 <input type="text" value="" onkeyup="new Create_table().add_str.call(this)" /> <script> function Create_table() { this.add_str = function () { alert(this.value); } } </script> 
  • one
    URAAAAAE !!!!!! Thank you. Your method has helped. - koza4ok
  • oh, unexpected! : D - lampa

Pass the current DOM element, namely this inside this handler.

  • Is there another way? - koza4ok