使用javascript / jQuery刷新特定的div内容 [英] Refreshing a particular div content using javascript / jQuery
问题描述
我有一个JQuery div元素。它在屏幕上显示一张图片。图像存储在设备内存中,并且正在以连续间隔(使用相同的文件名)进行替换
一旦显示图像它卡在那里,我希望它加载最新的图像(保存在内存中),当我在任何给定的时间访问这个div。
我使用JavaScript来开发这个应用程序。
任何帮助都不用理解。
[更新]
这是我的代码,只是显示图像的标准方式。
< img src =/ storage / emulated / 0 / Images / 1.pngwidth =128height =128>
p>
图像1.png将定期更换。我希望在屏幕上更新。
由于cordova相机插件只允许用户选择图像进行查看/编辑或者点击图片,然后我们可以使用cordova文件插件创建一个正常运行的图库应用程序。
将cordova文件插件添加到您的项目中:
cordova插件添加cordova-plugin-file
然后创建一个处理程序为您提供图像路径(语法):
lockquote
window.resolveLocalFileSystemURL(cordova.file.dataDirectory,function
(dirEntry){
console.log('file system open:'+ dirEntry.name);
var isAppend = true;
createFile(dirEntry,fileToAppend.txt ,isAppend);},onErrorLoadFs);
有关此插件的详细信息: ht tps://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/
您可以下载测试图库应用程序展示图像从 DCIM /相机文件夹(默认)转换为html img标签到用户屏幕上: https://drive.google.com/open?id=0B8vJcyO8_PK9R1k4STUyaEJQS1k
I have a JQuery div element. It displays a picture on the screen. The image is stored in the device memory and is being replaced in continuous interval (with same file name)
Once the image is displayed It's stuck there, I want it to load the latest image ( saved on the memory) by itself when ever I visit this div back in any given time.
Im using javascript to develop this App.
Any little help is appreciated.
[update]
This is my code, just the standard way to display the image.
<img src="/storage/emulated/0/Images/1.png" width="128" height="128">
The image 1.png will be replaced in regular intervals. I want this to be updated on the screen.
Since cordova camera plugin just allow user to select a image to view/edit or click a image then we can use cordova file plugin to create a functioning gallery app.
add cordova file plugin to your project:
cordova plugin add cordova-plugin-file
Then create a handler to provide you the path of the images(Syntax):
window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function (dirEntry) { console.log('file system open: ' + dirEntry.name); var isAppend = true; createFile(dirEntry, "fileToAppend.txt", isAppend); }, onErrorLoadFs);
For details of this plugin:https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/
You can download test gallery app showing images from DCIM/Camera folder(default) into html img tag onto user screen:
https://drive.google.com/open?id=0B8vJcyO8_PK9R1k4STUyaEJQS1k
这篇关于使用javascript / jQuery刷新特定的div内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!