1

Is there any way to set id for asm select instead of having it initiated automatically? Thank you in advanced.

<select multiple id="mySelect">
   <option value="volvo">Volvo</option>
   <option value="saab">Saab</option>
   <option value="opel">Opel</option>
   <option value="audi">Audi</option>
</select>

$("#mySelect").asmSelect({
    animate: true,
    addItemTarget: 'bottom'
});

I don't want the asmSelect id to be "asmSelect0", please show me how to change it. Thank you.

user3034683
  • 39
  • 3
  • 10

1 Answers1

0

It looks like this plugin renders an entirely new visual representation of your original select element and then hides it. The id for the new select container is a composition of options.selectClass + index. The selectClass is hard coded into the plugin and index is determined internally. The author left no exposed method to change these variables.

If you want this id to be different you'll need to change the options object in the plugin code itself or change the element's id with JavaScript after you call the plugin.

To change the ID afterwards just use the JQuery .attr method

$('#asmSelect0').attr('id', 'newId'); 

Replace newId with the id you choose.

Dan-Nolan
  • 6,594
  • 4
  • 27
  • 32
  • can you show me how to change the element's id with javascript after calling this? $("#mySelect").asmSelect({ animate: true, addItemTarget: 'bottom' }); thank you – user3034683 Nov 26 '13 at 03:25