javascript - How do i get Option Selected Data tag -


i can text , value want tag

this.options[this.selectedindex].value <---will value  this.options[this.selectedindex].text   <---will text 

i want data_id option

<option value="l w12 6.3 quattro" data-id="200480476">l w12 6.3 quattro</option> 

i have tried:

this.options[this.selectedindex].data-id 

and didn't work

i sorry add more info... using on nested forms in ruby on rails , have on change event set it:

<select id="shipment_vehicles_attributes_0_style" name="shipment[vehicles_attributes][0][style]" onchange="getstylesid(this.id,this.options[this.selectedindex].data-id)"><option value="">select style</option><option value="base" data-id="9058">base</option></select> 

can use jquery in there

your tags suggest using jquery. can this:

var attr = $('option:selected').attr( "data-id" );


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -