有人能指出我正确的方向吗?我有一个使用 jquery 和 fancybox 的网页,其中图像以花哨的宝丽来风格等显示。
我怎样才能使使用 html5 文件 APi 添加/上传的新照片将自己放入 div 中并应用必要的样式。下面是我需要添加图像的 div。因此,如果我上传 100 张图片,它们在上传后都会自动具有相同的样式。谢谢
<div id="view3">
<div id="polaroid"> <!--class for styling-->
<!--Image One-->
<figure><a class="fancybox" title="Image-1" href="images/1.png"><img src="images/1.png" width="250" height="200" alt="" /></a> <!--the image-->
<textarea>Image-1</textarea> <!--the caption that appears below the image-->
</figure>
最佳答案
您是否已经有了上传的处理程序并且只是想知道如何添加文件?在这种情况下,您可以这样做:
var parent = $("#polaroid"),
img = "<figure><a class='fancybox' title='Image-1' href='images/" + yourFile + "'><img src='" + yourFile + "' width='250' height='200' alt='' /></a>";
parent.append(img);
关于jquery - 上传后自动应用样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18841977/