<div class="htmlarea"> <textarea id="runcode49422"> </textarea> <br><input onclick="runEx('runcode49422')" type="button" value="运行代码"><input onclick="doCopy('runcode49422')" type="button" value="复制代码"> <input onclick="doSave(runcode49422)" type="button" value="保存代码"> <a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">[Ctrl A 모두 선택 참고: </a>외부 J를 도입해야 하는 경우 실행하려면 새로 고쳐야 합니다. </div>]<br><script type="text/javascript"> function MyColor(name,r,g,b){ this.name=name; this.red=r; this.green=g; this.blue=b; } MyColor.prototype.hexValue=function(){ var hR=this.red.toString(16); var hG=this.green.toString(16); var hB=this.blue.toString(16); return "#"+(this.red<16?("0"+hR):hR)+(this.green<16?("0"+hG):hG)+(this.blue<16?("0"+hB):hB); }; var CnLeiColor=new MyColor("red",255,0,0); alert(CnLeiColor.hexValue()); </script>