I am using this / library and I don't know how to show the value of the src image when clicked.
Can you help me?
This is my example:
$("select.image-picker.show-labels").imagepicker({
hide_select: true,
show_label: true,
clicked:function(){
console.log($(this).find("img").attr("src"));
}
});
I am using this http://rvera.github.io/image-picker/ library and I don't know how to show the value of the src image when clicked.
Can you help me?
This is my example:
$("select.image-picker.show-labels").imagepicker({
hide_select: true,
show_label: true,
clicked:function(){
console.log($(this).find("img").attr("src"));
}
});
Share
Improve this question
edited Oct 20, 2022 at 21:30
Brian Tompsett - 汤莱恩
5,89372 gold badges61 silver badges133 bronze badges
asked Jun 18, 2013 at 8:57
jcarloswebjcarlosweb
9742 gold badges15 silver badges34 bronze badges
1
- the value is undefined, thanks – jcarlosweb Commented Jun 18, 2013 at 9:03
1 Answer
Reset to default 7This should do it :
$(this).find("option[value='" + $(this).val() + "']").data('img-src');
$(this)
is the select input, you're trying to find the option which is selected and to get the img-src data attribute.
Though, are you sure you shouldn't just get the Id of the image you selected through $(this).val()
?