Javascript examples for jQuery:Tag Traversing
Add function to Object with an element selector
<html lang="en"> <body translate="no"> <button class="exampleButton">Test</button> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> function Object(name, button){ this.name = name;/*from w w w.j a v a2 s . c o m*/ this.button = button; } var ExampleOne = new Object('Example One', $('.exampleButton')); ExampleOne.button.click(function(e) { console.log('success!'); }); </script> </body> </html>