Select option not working in IE 8
The following code works fine in IE 7 and IE 6, but not in IE 8:
value = $("#ctl00_ContentApplication_cmbLocation option[text='"
+ $('#ct开发者_运维知识库l00_ContentApplication_lblResLocation').text() + "']").val();
Does anyone know why?
Could it be that you mean :contains(...)
instead of [text=...]
?
Try:
value = $("#ctl00_ContentApplication_cmbLocation option:contains('"+ $( '#ctl00_ContentApplication_lblResLocation' ).text() +"')").val();
For example, $('option:contains('text')
will match <option value='val'>text</option>
(but also <option value='val'>text and some more words</option>
).
These are ID from asp.net, the best way to detect it in jQuery is:
var div1 = $('[id$=cmbLocation]');
var div2 = $('[id$=lblResLocation]');
try and let me know.
精彩评论