javascript - How can I get jQuery to programmatically items in this select list using IE and FF consistently? -
I have some jQuery code that chooses an option in the selection list. For the first time, when an item works everything, it selects, although the items selected near the second pass through IE and FF are not cleaned. Chrome always works.
With the demo of what I see. I have tried to do both as $ ("testUpdate option: selected")
and $ ("testUpdate> option: selected")
selector, each only The first time I have tried to convert many tags into multiple.
Here is the HTML and the relevant failed jQuery. I am using jQuery 1.9.1, but on JSFiddle I see the same results with newer versions.
// HTML & lt; Id = "testUpdate" name = "testUpdateName" multiple = "multiple" size = "5" & gt; & Lt; Option value = "1" & gt; 1 & lt; / Options & gt; & Lt; Option value = "2" & gt; 2 & lt; / Options & gt; & Lt; Option value = "3" & gt; 3 & lt; / Options & gt; & Lt; Option value = "4" & gt; 4 & lt; / Options & gt; & Lt; Option value = "5" & gt; 5 & lt; / Options & gt; & Lt; / Select & gt; // jquery 2 pass $ ("# test update option: selected") fails. Each (function () {// this $ (this) is not executed .removeAttr ('selected');}); // Optional selector is always forced to check all the options / HTML is correct after this, but the blind list has not been selected / / I would not even want to because the actual list is hundreds of items ($ # TestUpdate Options "). Each (function () {$ (this) .removeAttr ('selected');});
selected
value is not added to the DOM element , And therefore is not an attribute of choice. You will get a $ Prop ()
:
$ ("# testUpdate option should use [value = '" + this.getCurrentSelectionValue (+) + "']". Sahara ('Selected' , 'Selected');
Comments
Post a Comment