jQuery Exif and async
jQuery Exif and async
我想在单击链接后加载图像,然后显示Exif数据。我有这样的代码。
<div class="row">
<div class="col-md-4 link">
<a id="link" href="http://77.45.18.218/Szprotawa/Zdjecia/teren-aparat/DSC02040.JPG" class="img-link">DSC02040.JPG</a>
</div>
<div class="col-md-4 image"></div>
<div class="col-md-4 exif"></div>
.JS
$("a").click(function(event) {
event.preventDefault();
console.log($(this).attr("href"));
var self = $(this);
var link = $(this).attr("href");
var img = $("<img />").attr('src', link).load(function() {
self.parent().parent().children('.image').append(img);
$(this).exifLoad(function() {
self.parent().parent().children('.exif').append($(this).exifAll());
});
});});
而且它不起作用。有人可能会看我有错误的地方吗?谢谢。
您可以像这样加载图像:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
function openImage(url)
{
var img = $('<img id="dynamic" />');
img.attr('src',url);
img.appendTo('.image');
}
</script>
</head>
<body>
<div class="row">
this is page
<div class="col-md-4 link">
<a id="link" href="javascript:openImage('http://77.45.18.218/Szprotawa/Zdjecia/teren-aparat/DSC02040.JPG')" >DSC02040.JPG</a>
</div>
<div class="col-md-4 image"></div>
<div class="col-md-4 exif"></div>
</body>
</html>
并且比之后,您可以在相同的功能中加载其他<div class="col-md-4 exif">
。
这是jsfiddle
相关文章:
- Selenium WebDriver and JavaScript change
- jQuery加载的async和ready函数不工作
- PHP and Javascript functions
- Javascript Return and if/else
- 什么'这是从第三个函数上的async 1st函数获得结果的更好方法
- SetTimeout and clearTimeout in Javascript
- lightbox in html 5 and javascript
- TimelineJS and AngularJS
- timeago.js with datatable and PHP
- Javascript change window.location and run async ajax get
- Typescript async/await and angular $q service
- jQuery Exif and async
- async.parallel on mongodb and Node.js
- async each and foreach functions
- async/await and recursion
- JavaScript async/await and do/while loop
- AngularJS UI-GRID: editDropdownOptionsFunction and async $ht
- Node.js and Async error
- ajax function and async: false
- forEach, async and callbacks