我正在寻找一个jQuery图像选择器插件,允许我执行以下操作:
>显示一组图像,让用户通过单击选择一个(并且只能选择一个)
>如果用户不喜欢任何指定的图像,他应该能够上传自己的图像
我知道并不难,但如果有一个人们使用的标准插件,我宁愿使用它而不是重新发明轮子.
解决方法
像这样的东西?我不知道是否有插件,但似乎很简单
- // HTML
- <div id="image_container">
- <img src="blabla" />
- <img src="blabla" />
- ...
- </div>
- <form ...>
- <input id="image_from_list" name="image_from_list" type="hidden" value="" />
- <input id="image_from_file" name="image_from_file" type="file" />
- </form>
- // JS
- $('div#image_container img').click(function(){
- // set the img-source as value of image_from_list
- $('input#image_from_list').val( $(this).attr("src") );
- });