javascript 之简单对象源代码

xiaoxiao2026-09-12  16

<html> <head> <title>test class </title> <mce:script type="text/javascript"><!-- function MyClass2(nId, strName) { this.id = nId; this.name = strName; this.Print = function () { var strMsg = 'id = ' + this.id + '\n'; strMsg += 'name = ' + this.name + '\n'; alert(strMsg); }; } try { var objTest1 = new MyClass2(1101, 'andylin'); alert(objTest1); alert('ok'); } catch (e) { alert(e); } var objTest = new Object(); objTest.id=1101; objTest.name='andylin'; objTest.Print = function (){alert('aaa'); }; // --></mce:script> </head> <body> <form name="click_form"> <input type="button" name="MyBtn" value="click" οnclick="objTest.Print()"> </form> </body> </html>

转载请注明原文地址: https://www.6miu.com/read-5052570.html

最新回复(0)