What’s the best way to accomplish something like this:
html.erb
<!-- inside a loop -->
<i htmlfor="wish">
<!-- name or icon -->
</i>
<input type="hidden" class="wish-cls" name="wish" value="<%= product.id %>" />
<!-- end loop -->
JavaScript
$(".wish").click(function(e){
e.preventDefault();
//var id = document.getElementsByTagName('wish-cls');
console.log("Clicked: " + e.target.value);
});
If I click the input, when not hidden, I get the value but how to achieve this using htmlfor
? Is it possible?