Skip to content

Instantly share code, notes, and snippets.

@Chion82
Created July 9, 2015 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chion82/bfc26ba0966fca5c3600 to your computer and use it in GitHub Desktop.
Save Chion82/bfc26ba0966fca5c3600 to your computer and use it in GitHub Desktop.
<!--TODO : 修改图片路径 -->
<img src="test.jpg" id="pic" />
<textarea id="result_text" rows="10" cols="30">
</textarea>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
(function() {
function get_init_point(e) {
x = e.pageX - $('#pic').offset().left;
y = e.pageY - $('#pic').offset().top;
$('#result_text').val(x + ',' + y);
}
document.getElementById('pic').onmousedown = get_init_point;
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment