First we can traverse dropdown
var array = new Array ();
$ ("#select option"). each (function (j) {
array[j]=$ (This). Val ();
$ ("#select option[value=" +this.value+ "]"). Remove ();
});
The values in the drop-down box are stored in an array and then move, and then compared to the array in JSON
for (var i = 0;i<accountnoarr.length;i++) {
for (Var k=0;k<array.length;k++) {
if (Accountnoarr[i].accountno==array[k]) {
$ ("#Select "). Append ("<option value= '" +array[k]+ ">" +array[k]+ "</option>");
}
}
}
Put the same append in the Select.
var temp = "AA";
$ ("#select option"). Filter (function () {
return $ (this). val () = = temp; The value of option for select is equal to Temp (AA).
}). Prop (' selected ', true). Text ();
This is directly the description of the Select.
The drop-down box displays only the values in the initial drop-down box and the JSON returns the intersection of the array