Application Scenarios:
Gets the value of the page Li key below, added to the ARR array
Delete the value of the model that is not in the ARR array.
Example code:
var getsalemodels = function (brand_id) {
if (brand_id) {
var li = $ (". Pinpai-chexing" +brand_id+ "Li");
var arr = new Array ();
if (Li.length > 0) {
Li.each (function (index, Element) {
Arr.push (Element). Children ("a"). attr ("Data-value"));
});
}
}
return arr;
}
Application
Get car
var Getmodel = function (ID) {
var arr = getsalemodels ($ ("#brand_id"). attr ("Data-value"));
$.getjson ("/interface/carbase/gettuangoumodels/", {id:$ ("#brand_id"). attr ("Data-value")},function (JSON) {
var models = $ (". Models");
var option = "";
$ (models). Find ("Li"). empty (); Clear the original options
if (JSON) {
$.each (Json.data,function (Index,array) {
Removal of discontinued models
if ($.inarray (array[' model_id '],arr)!=-1) {
if (!index) {
$ ("#model_id"). attr ("Data-value", array[' model_id ']);
$ ("#model_id"). Text (array[' model ');
}
Option + = "<li data-value= '" +array[' model_id ']+ "'";
Option + = ">" +array[' Model ']+ "</li>";
}
});
Models.append (option);
}
});
return false;
}
jquery gets the Li array from the page, deleting the key that is not in the array