jquery错误怎么调试?
<script type="text/javascript">
$(document).ready(function() {
var api = $.Jcrop("#ctl00_DefaultContent_xuwanting", {
setSelect: [0, 0, 120, 120] //setSelect是Jcrop插件内部已定义的运动方法
});
//记得放在jQuery(window).load(...)内调用,否则Jcrop无法正确初始化
$("#ctl00_DefaultContent_xuwanting").Jcrop({
onChange: showPreview,
onSelect: showPreview,
aspectRatio: 1
});
//简单的事件处理程序,响应自onChange,onSelect事件,按照上面的Jcrop调用
function showPreview(coords) {
if (parseInt(coords.w) > 0) {
//计算预览区域图片缩放的比例,通过计算显示区域的宽度(与高度)与剪裁的宽度(与高度)之比得到
var rx = $("#preview_box").width() / coords.w;
var ry = $("#preview_box").height() / coords.h;
//通过比例值控制图片的样式与显示
$("#crop_preview").css({
width: Math.round(rx * $("#ctl00_DefaultContent_xuwanting").width()) + "px", //预览图片宽度为计算比例值与原图片宽度的乘积
height: Math.round(rx * $("#ctl00_DefaultContent_xuwanting").height()) + "px", //预览图片高度为计算比例值与原图片高度的乘积
marginLeft: "-" + Math.round(rx * coords.x) + "px",
marginTop: "-" + Math.round(ry * coords.y) + "px"
});
rx = $("#preview_box1").width() / coords.w;
ry = $("#preview_box1").height() / coords.h;
//通过比例值控制图片的样式与显示
$("#crop_preview1").css({
width: Math.round(rx * $("#ctl00_DefaultContent_xuwanting").width()) + "px", //预览图片宽度为计算比例值与原图片宽度的乘积
height: Math.round(rx * $("#ctl00_DefaultContent_xuwanting").height()) + "px", //预览图片高度为计算比例值与原图片高度的乘积
marginLeft: "-" + Math.round(rx * coords.x) + "px",
marginTop: "-" + Math.round(ry * coords.y) + "px"
});
rx = $("#preview_box2").width() / coords.w;
ry = $("#preview_box2").height() / coords.h;
//通过比例值控制图片的样式与显示
$("#crop_preview2").css({
width: Math.round(rx * $("#ctl00_DefaultContent_xuwanting").width()) + "px", //预览图片宽度为计算比例值与原图片宽度的乘积
height: Math.round(rx * $("#ctl00_DefaultContent_xuwanting").height()) + "px", //预览图片高度为计算比例值与原图片高度的乘积
marginLeft: "-" + Math.round(rx * coords.x) + "px",
marginTop: "-" + Math.round(ry * coords.y) + "px"
});
$('#ctl00_DefaultContent_txtX').val(coords.x);
$('#ctl00_DefaultContent_txtY').val(coords.y);
$('#ctl00_DefaultContent_txtX2').val(coords.x2);
$('#ctl00_DefaultContent_txtY2').val(coords.y2);
$('#ctl00_DefaultContent_txtWidth').val(coords.w);
$('#ctl00_DefaultContent_txtHeight').val(coords.h);
}
}
});
function ReSet() {
var api = $.Jcrop("#ctl00_DefaultContent_xuwanting", {
setSelect: [0, 0, 120, 120] //setSelect是Jcrop插件内部已定义的运动方法
});
//记得放在jQuery(window).load(...)内调用,否则Jcrop无法正确初始化
$("#ctl00_DefaultContent_xuwanting").Jcrop({
onChange: showPreview,
onSelect: showPreview,
aspectRatio: 1
});
//简单的事件处理程序,响应自onChange,onSelect事件,按照上面的Jcrop调用
function showPreview(coords) {
if (parseInt(coords.w) > 0) {
//计算预览区域图片缩放的比例,通过计算显示区域的宽度(与高度)与剪裁的宽度(与高度)之比得到
var rx = $("#preview_box").width() / coords.w;
var ry = $("#preview_box").height() / coords.h;
//通过比例值控制图片的样式与显示
$("#crop_preview").css({
width: Math.round(rx * $("#ctl00_DefaultContent_xuwanting").width()) + "px", //预览图片宽度为计算比例值与原图片宽度的乘积
height: Math.round(rx * $("#ctl00_DefaultContent_xuwanting").height()) + "px", //预览图片高度为计算比例值与原图片高度的乘积
marginLeft: "-" + Math.round(rx * coords.x) + "px",
marginTop: "-" + Math.round(ry * coords.y) + "px"
});
rx = $("#preview_box1").width() / coords.w;
ry = $("#preview_box1").height() / coords.h;
//通过比例值控制图片的样式与显示
$("#crop_preview1").css({
width: Math.round(rx * $("#ctl00_DefaultContent_xuwanting").width()) + "px", //预览图片宽度为计算比例值与原图片宽度的乘积
height: Math.round(rx * $("#ctl00_DefaultContent_xuwanting").height()) + "px", //预览图片高度为计算比例值与原图片高度的乘积
marginLeft: "-" + Math.round(rx * coords.x) + "px",
marginTop: "-" + Math.round(ry * coords.y) + "px"
});
rx = $("#preview_box2").width() / coords.w;
ry = $("#preview_box2").height() / coords.h;
//通过比例值控制图片的样式与显示
$("#crop_preview2").css({
width: Math.round(rx * $("#ctl00_DefaultContent_xuwanting").width()) + "px", //预览图片宽度为计算比例值与原图片宽度的乘积
height: Math.round(rx * $("#ctl00_DefaultContent_xuwanting").height()) + "px", //预览图片高度为计算比例值与原图片高度的乘积
marginLeft: "-" + Math.round(rx * coords.x) + "px",
marginTop: "-" + Math.round(ry * coords.y) + "px"
});
$('#ctl00_DefaultContent_txtX').val(coords.x);
$('#ctl00_DefaultContent_txtY').val(coords.y);
$('#ctl00_DefaultContent_txtX2').val(coords.x2);
$('#ctl00_DefaultContent_txtY2').val(coords.y2);
$('#ctl00_DefaultContent_txtWidth').val(coords.w);
$('#ctl00_DefaultContent_txtHeight').val(coords.h);
}
}
}
</script>
[解决办法]
FireBug
[解决办法]
页面加载的时候老是说
$(document).ready(function() {
这里是NULL[解决办法]
求高手
[解决办法]
调试jquery:
引用jquery的源代码,在ie下,F12,选择“脚本”,启动调试,刷新页面
[解决办法]
调试很多方法:
1.弹框alert()
2.第三方插件
------解决方案--------------------
ie8自代,或按f12
[解决办法]
你应该是之前还引用了其他插件,大概是被修改了
你把这段代码放在所有必要引用之后看看
[解决办法]
我以前写是用火狐的firebug进行调试的,挺好用的,记得结贴哦!
[解决办法]
还没结贴!!
FireFox调试下载地址
http://www.lupaworld.com/portal-view-aid-207859.html
https://addons.mozilla.org/zh-cn/firefox/addon/firebug/