jquery selectedIndex doesn't work

Related searches

i have a from with many select tags , when the user submit the form i want to check if the user choose one option for all the select tags and this is my jquery code

$('#apForm select').each(function(){
            var $this = $(this);
            if ($this.selectedIndex == 0){
                var error = 'fill this please' ;
                errorCount = errorCount + 1;   

and i tried like this


i just give you the piece of my code where my question is if i should give more code tell me

thank you for help

var $this = $(this);
if($this.get(0).selectedIndex == 0) {


or just simple

this.selectedIndex; // not $this / $(this)

If no option it will return -1

here I showed all above cases

Set the selected index of a Dropdown using jQuery, selectedIndex = 0; // sets selected index to first item using jQuery (can I mean, they change the selected index, but it doesn't actually reflect on� Adding [0] converts the jquery object to a javascript object which has the selectedIndex property. This example won't work without [0] – Aram May 21 '14 at 23:28 @JasonL.: selectedIndex is a property, and there is no corresponding attribute.

#1474 (setting selectedIndex doesn't update dropdown position , selectedIndex = 3;. which does change the dropdown position. use with <form> < select name="myDropdown" id="myDropdown"> <option value="a">a</option>� Why doesn't $("#b6").selectedIndex = $("#s6").selectedIndex; work? (Assuming #b6 and #s6 are similar select boxes of course. Copying billing to shipping

If you are using a version of jQuery above 1.6? then you can use

if ( $this.prop('selectedindex') == 0 ){ /* handle */ }

selectedIndex | Search Results, Get the value of a property for the first element in the set of matched elements or set one or more properties for every matched element. Attributes | Manipulation� There is no *attribute* named selectedIndex so the code above is invalid. Using .prop doesn't change anything, still doesn't work. comment:7 follow-up: 8 Changed 9 years ago by prakashsinha12@…

How to set dropdownlist selected index?, but what I try doesn't work, please help. the code I try using jquery: $('#IDName : selected').val() = 2; $("#� jQuery Get Selected Index Examples – 2 Ways At times, it could be very useful to use jQuery to Get Selected Option Index value for carrying out relevant processing. In this article, I am going to show you a very easy and simple way to get selected option index value using jQuery .

HTML DOM Select selectedIndex Property, Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to� I strongly prefer the first, but as stated above, this is undefined behavior for jQuery right now: "Value not found" sets selectedIndex = -1. Subsequent .val() returns null. "Value not found" sets selectedIndex = 0 (more technically, to the lowest selectedIndex identifying a non-disabled <option>). Subsequent .val() returns the corresponding value.

The button with ID demo is attached with a click event. When the button is clicked the selectedIndex of the HTML Select Dropdown with ID mySelect is set using jQuery