javascript - Dropdown options can't access with jquery selector? -


i have drop down in webpage.it's aspx page.but try access drop down javascript.here code. code working.

var = document.getelementbyid('mydropdown'); alert(a.options.length); 

this code not working

var = $('#mydropdown'); alert(a.options.length); 

i getting following error.

typeerror: cannot read property 'length' of undefined 

any 1 have idea.

$('#mydropdown') jquery object , treating dom object. try changing

var = $('#mydropdown'); 

to

var = $('#mydropdown')[0]; 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -