本文介紹了jQuery 圖像選擇器的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在尋找一個 jQuery 圖像選擇器插件,它允許我執行以下操作:
I'm looking for a jQuery image picker plugin that allows me to do the following:
- 顯示一組圖像并讓用戶通過單擊選擇一個(并且僅一個)
- 如果用戶不喜歡任何指定的圖片,他應該可以上傳自己的
只需 #1 就足夠了,因為如果需要我可以添加 #2 的代碼
Just #1 would suffice, as I can add the code for #2 if necessary
我知道這并不難,但如果有一個標準插件可供人們使用,我寧愿使用它也不愿重新發明輪子.
It's not that difficult to do I know, but if there is a standard plugin that people use for this, I'd rather use that than reinvent the wheel.
推薦答案
像這樣?我不知道是否有插件,但似乎很簡單
Something like this? i dont know if there is plugin but is seems really simple
// 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") );
});
這篇關于jQuery 圖像選擇器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!