js调试工具console.log()方法查看js代码的执行情况
人气:0我之前在调试代码的时候,跟砸js代码执行情况,一般都是通过在代码块中使用alert的方式查看js代码的执行情况,今天也是看到有朋友使用console.log函数打印输出函数,变量,对象,下边就console.log的使用情况进行记录,具体的语法是:
console.log("值为:",fn);
console.log()能够输出变量,函数,数组,对象等等
<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'); /https://img.qb5200.com/download-x/document.getElementById('firstname').value = "zhang"; /https://img.qb5200.com/download-x/document.getElementById("test1").value = this.content; /https://img.qb5200.com/download-x/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>
加载全部内容