I have the following code:
var selected = $(\'#hiddenField\').val().split(\",\");
...
if (selected.indexOf(id) > 0) {
... set value ...
}
There's an jQuery method to overcome the lack of indexOf(), you can use .inArray() instead:
var selected = $('#hiddenField').val().split(",");
if ($.inArray(id, selected) > -1) {
... set value ...
}
jQuery.inArray() exists for just this reason...if you're including jQuery already, no need to write the function again. Note: This actually returns a number, like indexOf() would.