javascript - Change value of Tag in LocalStorage -
i have localstorage xml called classification save name of teams , points.
i want go tag points , change value on time add new result.
my localstorage is:
<classification><classification id="1"><name>sl benfica</name><points>0</points ></classification> <classification id="2"><name>fc porto</name ><points>0</points></classification> <classification id="3"><name>sporting cp</name><points>0</points></classification> <classification id="4"><name>sc braga</name><points>0</points></classification> </classification>
i want read value of points , add +3 when add new result of game.
javascript:
if (localstorage.classification){ parser = new domparser(); var doc =parser.parsefromstring(localstorage.classification,"text/xml"); var n = doc.getelementsbytagname("classification")[0].childnodes.length; var = 0; } (i = 0; < n; i++) { elem = doc.getelementsbytagname("classification")[0].childnodes[i]; equipaclassificacao = elem.getelementsbytagname("name")[0].firstchild.nodevalue; if (resultgame == 1) { pointsg = number(elem.getelementsbytagname("points")[0].firstchild.nodevalue); pointsg += 3; } }
someone know how resolve this?
Comments
Post a Comment