html5中文学习网

您的位置: 首页 > 网站及特效实例 > javascript特效 » 正文

js调试工具console.log()方法查看js代码的执行情况_javascript技巧_

[ ] 已经帮助:人解决问题

我之前在调试代码的时候,跟砸js代码执行情况,一般都是通过在代码块中使用alert的方式查看js代码的执行情况,今天也是看到有朋友使用console.log函数打印输出函数,变量,对象,下边就console.log的使用情况进行记录,具体的语法是:nUuHTML5中文学习网 - HTML5先行者学习网

console.log("值为:",fn);

console.log()能够输出变量,函数,数组,对象等等nUuHTML5中文学习网 - HTML5先行者学习网

<html> <head> <title>this关键字_函数调用</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head> <body> <input type="text" id="test1" name="firstname" value="" /> <input type="text" id='lastname' name='lastname' value=''> </body> <script type="text/javascript"> var testobj = { 'id': 1, 'content': 'test', 'firstname': function() { var EleFirst= document.getElementById('test1'); //document.getElementById('firstname').value = "zhang"; //document.getElementById("test1").value = this.content; //document.getElementById("test1").setAttribute("value","zhang"); //this.content = val; EleFirst.setAttribute("value",this.content); console.log("对象的值为:",test1);//对象的值为:<input type="text" id="test1" name="firstname" value="" /> }, 'lastname': function() { document.getElementById('lastname').value = "ying"; } }; console.log(testobj);/** 打印对像**/ testobj.firstname(); testobj.lastname(); </script> </html>
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助