Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery中的ImgAreaSelect_Javascript_Jquery_Img Area Select Jquery - Fatal编程技术网

Javascript jquery中的ImgAreaSelect

Javascript jquery中的ImgAreaSelect,javascript,jquery,img-area-select-jquery,Javascript,Jquery,Img Area Select Jquery,我是jquery新手。我在jquery中的任务是“ImgAreaSelect” 我从早上就开始尝试,但没有达到目标。请查看我的代码: <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="css/imgareaselect-default.css" /> <script src="http://ajax.googleapis.com/ajax/li

我是jquery新手。我在jquery中的任务是“ImgAreaSelect” 我从早上就开始尝试,但没有达到目标。请查看我的代码:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/imgareaselect-default.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="http://odyniec.net/projects/imgareaselect/css/imgareaselect-animated.css"></script>
<script>
    $(document).ready(function () {
    $('#ladybug_ant').imgAreaSelect({
        handles: true,
        onSelectEnd: function(img, selection){
            if (!selection.width || !selection.height){
                return;
            }
            $('#x1').val(selection.x1);
            $('#y1').val(selection.y1);
            $('#x2').val(selection.x2);
            $('#y2').val(selection.y2);
            $('#w').val(selection.width);
            $('#h').val(selection.height); 
        }
    });
});

    </script>
</head>
<body>
   <img src="http://jotform.org/demo/jquery-image-area-select-plugin/images/sweet-dogs.jpg" id="ladybug_ant">
</body>
</html>

$(文档).ready(函数(){
$('ladybug_ant')。imgAreaSelect({
是的,
onSelectEnd:功能(img,选择){
如果(!selection.width | |!selection.height){
返回;
}
$('#x1').val(selection.x1);
$('#y1').val(selection.y1);
$('#x2').val(selection.x2);
$('y2').val(selection.y2);
$('#w').val(selection.width);
$('#h').val(selection.height);
}
});
});

您似乎缺少必须从中下载的插件本身

jQuery只是核心,不包括图像区域选择方法

加载插件后,您将能够使用
$('#ladybug_ant').imgAreaSelect({..})


这是一个例子

我也面临这个问题。我在Css和Bingo中做了一些更改,它得到了解决。 实际上,父div位置应该是相对的,以使imagearea可滚动

您必须定义“parent:“imgParentDivID”并设置该div的位置:relative。 它将完美地工作

代码:

<div id="imgParentDivID" style="position:relative">
<img id="imgID" src="http://jotform.org/demo/jquery-image-area-select-   plugin/images/sweet-dogs.jpg" id="ladybug_ant">
</div>

$("#imgID").imgAreaSelect({
        parent: "#imgParentDivID",           
            aspectRatio: '1:1',
            handles: true,
            fadeSpeed: 200,
            selectionOpacity: 1,               
            onSelectChange: preview
        });       

$(“#imgID”).imgAreaSelect({
父项:“imgparentvid”,
aspectRatio:'1:1',
是的,
时尚种子:200,
选择容量:1,
onSelectChange:预览
});       

我希望这将对您有所帮助。

您已将脚本标记用于css链接。使用“链接”标记代替“脚本”标记,也就是使用

<link rel="stylesheet" type="text/css" href="http://odyniec.net/projects/imgareaselect/css/imgareaselect-animated.css"/>

而不是

<script src="http://odyniec.net/projects/imgareaselect/css/imgareaselect-animated.css"></script>


这将解决问题,无需进一步更改。

您的问题是什么?什么不起作用。一点输入:尝试在html代码之后添加javascript/imgareaselect代码