title: Dynamiclly change element CSS style using Ajax + JSON
body: <p>To simplify the question let's say I have a group of checkboxes (if selected - a specific style applied) and a href link.</p>
  <pre><code>&lt;input type=checkbox  style=&quot;color:#0f0; background:#0f0; border:1px solid;&quot; name=CHKB_3D unchecked&gt;
  &lt;span id=CHKB_3D_span style=&quot;&quot;&gt;3D Model&lt;/span&gt;&lt;br/&gt;
  &lt;input type=checkbox  name=CHKB_2D checked&gt;
  &lt;span id=CHKB_2D_span style=&quot;color:#00D100;&quot;&gt;2D Drawing&lt;/span&gt;&lt;br/&gt;
  &lt;input type=checkbox  name=CHKB_ST checked&gt;
  &lt;span id=CHKB_ST_span style=&quot;color:#00D100;&quot;&gt;Stack up&lt;/span&gt;&lt;br/&gt;
  &lt;a onclick=&quot;ajax_json_styling()&quot; href=&quot;javascript:void(0);&quot;&gt;click me to change style!&lt;/a&gt;
  </code></pre>
  <p><img src="https://i.stack.imgur.com/WxgTX.png" alt="enter image description here" /></p>
  <p>The values of the checkboxes status are stored in the database.
  The server (PHP) should decide which new color of checkbox label (span) I will have.
  If not selected -&gt; while, if selected -&gt; green.</p>
  <p>I have a working version of this behavior:
  When I press href &quot;save&quot;, I send ajax request to php, then on server side I write the new values of the status of the checkboxes. Then I create and echo a hidden DIV (later it's content will be eval() to apply new style) with specific styles that is based on current server data for checkboxes.
  Then in Ajax I eval() the content of that hidden DIV and in that way apply new styling based on server data for checkboxes.</p>
  <p>The challenge is to migrate from eval() to JSON+JSON.parse().
  I know how to update multiple DIVs content with JSON (in Ajax I hardcode which DIV with a specific ID to update). But my situation is a bit different, because I need to decide on the server side which element to update (based on DB records).</p>
  <p>I don't need hardcoded code in JS or JQuery on which element to apply styling, but the choice of which element should be done grammatically based on server side.</p>
  <p>Can I do that with JSON?</p>
  <p>Please provide a logic or a simple example on how I can do that.</p>
  <p>Thank you in advance for any help!</p>