Javascript examples for Object:this
Use "this" reference of the element calling the function
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> </head> /*from www. ja v a 2 s . co m*/ <body> Click first on [Run with JS] button <br> <br> <button name="somename1">Button1</button> <button name="somename2">Button2</button> <script> $('button[name^=somename]').click(function(){ var myName = this.name; console.log(myName); }); </script> </body> </html>