jquery - Change text of option value with image -


i need change text images in option value. html code this:

<select id="topics" class="taxonomies-filter-widget-input" name="topics"> <option value="0">todas</option> <option class="level-0" value="unaestrella">una estrella</option> <option class="level-0" value="dosestrellas">dos estrellas</option> <option class="level-0" value="tresestrellas">tres estrellas</option> <option class="level-0" value="cuatroestrellas">cuatro estrellas</option> <option class="level-0" value="cincoestrellas">cinco estrellas</option> </select> 

i change "una estrella" image "http://www.domain.com/images/unaestrella.png" example. possible?

thanks!

no not . becuase option element can have text . can change tex jquery using

$('option[value="unaestrella"]').text('some lame text') 

or can take @ jquery plugins (which mimic select functionality enable have images in them ) @pls said ;

here plugins :

ddslick

image picker

how use ddslick

first need creat array of objects this

//dropdown plugin data var dddata = [     {         text: "facebook",         value: 1,         selected: false,         description: "description facebook",         imagesrc: "http://dl.dropbox.com/u/40036711/images/facebook-icon-32.png"     },     {         text: "twitter",         value: 2,         selected: false,         description: "description twitter",         imagesrc: "http://dl.dropbox.com/u/40036711/images/twitter-icon-32.png"     },     {         text: "linkedin",         value: 3,         selected: true,         description: "description linkedin",         imagesrc: "http://dl.dropbox.com/u/40036711/images/linkedin-icon-32.png"     },     {         text: "foursquare",         value: 4,         selected: false,         description: "description foursquare",         imagesrc: "http://dl.dropbox.com/u/40036711/images/foursquare-icon-32.png"     } ]; 

and just

$('#demobasic').ddslick({     data: dddata,     width: 300,     imageposition: "left",     selecttext: "select favorite social network",     onselected: function (data) {         console.log(data);     } }); 

note: code above taken staight website :) .


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -