2012-03-22 18 views
6

透明な矩形を表示するか、選択領域をクリックしてドラッグするか(desctop OSのように)、イメージの一部を選択する方法が必要です。どちらも私のために働くだろう。次に、jQueryで選択した領域の座標を取得する必要があります。イメージの一部を選択してjQueryで座標を取得します

サンプルやツイート(ある場合)、メソッドやAPIドキュメントのセクションを参考にしてください。ありがとう!

+1

jCropあなたがそのコードhttps://github.com/tapmodo/Jcrop/blob/master/js/jquery.Jcrop.jsをチェックかもしれないので、似たような操作を行います –

答えて

13

Jcropを参照してください。デモです。

<!-- This is the image we're attaching Jcrop to --> 
<img src="demo_files/pool.jpg" id="target" alt="Flowers" /> 

、スクリプト:

<script type="text/javascript"> 

jQuery(function($){ 

    $('#target').Jcrop({ 
    onChange: showCoords, 
    onSelect: showCoords 
    }); 

}); 

// Simple event handler, called from onChange and onSelect 
// event handlers to show an alert, as per the Jcrop 
// invocation above 

function showCoords(c) 
{ 
    alert('x='+ c.x +' y='+ c.y +' x2='+ c.x2 +' y2='+ c.y2) 
    alert('w='+c.w +' h='+ c.h) 
}; 

</script> 
+1

http://deepliquid.com/projects/Jcrop/demos.php?demo=handlerこれは、私が必要としていたものです。ありがとう! – Nikolay

+1

素晴らしいソリューションは、年齢を検索していました。ありがとう。 – Ukuser32

関連する問題