OK So I have this piece of code :
var el = {a:"b","isSel":true};
$.each(el,function(k,v){
if(k=="isSel"){
v=false
}
})
console.log(el);
but that doesn't change isSel to false... any clues?
Change it to
var el = {a:"b","isSel":true};
$.each(el,function(k,v){
if(k=="isSel"){
el[k]=false // <= this sets the property named k of el
}
})
console.log(el);
Note that if you just want to change the property named "isSel" of el, you don't have to iterate : you may simply do
el["isSel"] = false;
or
el.isSel = false;
There is no need for looping. The value can be accessed as follows:
el.isSel = false;
or
el["isSel"] = false;
if ("isSel" in el) el["isSel"]=false;