there are many examples out there of how to loop through Select Options, e.g.
Iterate through <select> options
but my problem is that I have to loop through an HTML string e.g. :
var s = "<option value="0">OptA</option><option value="1">OptB</option><option value="2">OptC</option>"
How can I loop through each item please?
the idea is that I have a string obtained from a dropdownlist.innerHTML, and an ID to find between all the options in the innerHTML:
GetValueFromHTML(iValueToFind,strHTML){
$(strHTML).each(function () {
var iTempValue =
var OptionText =
if (iTempValue == iValueToFind){
alert(OptionText );
}
})
}
This seems to give the result you want, you were very close. Just needed the
$(this).val()really:http://jsfiddle.net/K2p9n/