js调试工具console.log()方法查看js代码的执行情况
作者:bea
我之前在调试代码的时候,跟砸js代码执行情况,一般都是通过在代码块中使用alert的方式查看js代码的执行情况,今天也是看到有朋友使用console.log函数打印输出函数,变量,对象,下边就console.log的使用情况进行记录,具体的语法是: console.log("值为:",fn); console.log()能够输出变量,函数,数组,对象等等 <html> <head> <title>this关键字_函数调用</
我之前在调试代码的时候,跟砸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');
//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>
有用 | 无用
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');
//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>
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- jQuery实现的一个自定义Placeholder属性插件
- javascript中解析四则运算表达式的算法和示例
- javascript实现的平方米、亩、公顷单位换算小程序
- jquery访问ashx文件示例代码
- jQuery实现的一个tab切换效果内部还嵌有切换
- JavaScript动态改变HTML页面元素例如添加或删除
- 网页运行时提示对象不支持abigimage属性或方法
- js中直接声明一个对象的方法
- 点击标签切换和自动切换DIV选项卡
- js中window.open打开一个新的页面
- window.location.href的用法(动态输出跳转)
- Nodejs+express+html5 实现拖拽上传
- javascript父、子页面交互技巧总结
- jQuery的animate函数学习记录
- jQuery中get和post方法传值测试及注意事项
- JSON.stringify转换JSON时日期时间不准确的解决方法
- js事件监听机制(事件捕获)总结
- 使用jquery.qrcode生成彩色二维码实例
- 兼容最新firefox、chrome和IE的javascript图片预览实现代码