javascript – jQuery图像选择器

前端之家收集整理的这篇文章主要介绍了javascript – jQuery图像选择器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在寻找一个jQuery图像选择器插件,允许我执行以下操作:

>显示一组图像,让用户通过单击选择一个(并且只能选择一个)
>如果用户不喜欢任何指定的图像,他应该能够上传自己的图像

只需#1即可,因为我可以在必要时为#2添加代码

我知道并不难,但如果有一个人们使用的标准插件,我宁愿使用它而不是重新发明轮子.

解决方法

像这样的东西?我不知道是否有插件,但似乎很简单
  1. // HTML
  2. <div id="image_container">
  3. <img src="blabla" />
  4. <img src="blabla" />
  5. ...
  6. </div>
  7. <form ...>
  8. <input id="image_from_list" name="image_from_list" type="hidden" value="" />
  9. <input id="image_from_file" name="image_from_file" type="file" />
  10. </form>
  11. // JS
  12. $('div#image_container img').click(function(){
  13. // set the img-source as value of image_from_list
  14. $('input#image_from_list').val( $(this).attr("src") );
  15. });

猜你在找的jQuery相关文章