Sten Ka Razin Sten Ka Razin - 1 month ago 13
Javascript Question

image picker preselect item on initialization

I'm using image-picker from http://rvera.github.io/image-picker/ and I would like to preselect an image during the page load. I've tried this:

$('#image_picker option[value="54fdada12476"]').prop('selected',true);

$("#image_picker").imagepicker(...


But doesn't work. Also tried selected option for image-picker and jquery attr(). Is there an easy way to select by value?

Regards,

Answer

Ok, got it:

 $("#image_picker").find('option[value="54fdada12476"]').prop('selected',true);

this selects the desired option