Can someone help me figure out why my simple image change on a dropdown isn't working correctly?
You can find the code on this Jsfiddle.
Thank you for any assistance!
$("#display_avatar").change(function(){
$("img[name=preview]").attr("src", $("option").attr("imagePath"));
event.preventDefault();
});
<img src="http://placehold.it/100/0000FF/000000" name="preview" /><br /><br />
<select class="form-control" name="display_avatar" id="display_avatar">
<option value="1" imagePath="http://placehold.it/100/cccccc/000000">First</option>
<option value="2"imagePath="http://placehold.it/100/ghghgh/000000">Second</option>
<option value="3"imagePath="http://placehold.it/100/5fgrty/000000">Third</option>
<option value="4"imagePath="http://placehold.it/100/ff0000/000000">Fourth</option>
</select>