I have an unordered list, with each list item attributed with an id that will contain a location code. After receiving an ajax response from the server, I am provided with an array of location codes that may or may not match the ones in my unordered list; if they do, I need to add a class of "on" to each list item.
What I need is the js needed to parse the json response and then the logic to add the css class if a location code matches one in my list.
Should be trivial for a js ninja, complicated for a novice like me!
<li id="a7456">Location 1</li>
<li id="a7457">Location 2</li>
<li id="a7458">Location 3</li>
<li id="a7459">Location 4</li>
// and if a location code matches
<li id="a7456" class="on">Location 1</li>