Would like some assistance on implementing a voting system for users to select their preferred icon from an icon font used on my website. The icons are displayed via HTML and CSS. How can I achieve this functionality using jQuery, and then display the selected icon on the front end while also passing its value through a form?
Considering I cannot nest an input element inside another input, here is the approach I took:
Started off with this jsFiddle example: http://jsfiddle.net/6NVpL/42/
HTML:
<div class="iconDisplay">Display's selected icon</div>
<button class="selectIcon">Select Icon</button>
<div id="iconSelector">
<span class="icon-icon1"></span>
<span class="icon-icon2"></span>
<span class="icon-icon3"></span>
<span class="icon-icon4"></span>
<span class="icon-icon5"></span>
<span class="icon-icon6"></span>
<span class="icon-icon7"></span>
<span class="icon-icon8"></span>
</div>
JS:
$(".selectIcon").click(function () {
$("#iconSelector").fadeToggle();
});
$("#iconSelector span").click(function () {
$(this).click(function(){
$("#iconSelector").hide();
});
});