#35585519 · 13 Mar 2013, 18:02 · · პროფილი · პირადი მიმოწერა · ჩატი
ესეთი პრობლემა მაქ onclick ზე რო ვიძახებ this ში კალსაი აღარ არი და html ელემენტი მოდის მარა მე html ელემენტიც მჭირდება და კლასიც
| HTML | <html> <head> <meta charset="utf8"> <title>java[ertad]script კლასები</title> <script src="http://code.jquery.com/jquery.min.js"></script> </head> <body> <script>
var person = function(firstname,lastname){ this.firstname = firstname; this.lastname = lastname; return this; }; person.prototype.echo = function() { alert("firstname: "+this.firstname+" \nlastname: "+ this.lastname); }; person.prototype.button = function() { $(document.createElement("button")) .html(this.firstname) .on("click",this.echo) .appendTo("body"); }; var persons = []; persons[1] = new person("ჯუმბერ","ტყაბლაძე"); persons[2] = new person("ჟიმნი","მებონია"); persons[1].echo(); persons[1].button(); </script> </body> </html>
|
|