Reputation: 1261
I'm working on a project where I'm parsing a json file to get the contents then do $.post using php to update changes. I'm able to read and write without any issues.
However, after I parse the data from json, I if I make any changes like adding a new class via click it adds the class but doesn't apply the css.
Ex:
<div id="someID">lorem ipsum</div> <!-- (assuming I am "appending" this div via jquery and if I clicked on this div)
<!-- it will become -->
<div id="someID" class="red">lorem ipsum</div> <!-- the text and/or background should be red -->
I think I can apply a style="color: red" instead of applying class but I don't want that.
Any suggestions on how I can make this dynamic/live? Thanks.
Upvotes: 1
Views: 3179
Reputation: 2798
$("#someID").addClass("class_name_you_want_to_add");
for further reference you may want to look at http://api.jquery.com/addClass/
Upvotes: 2
Reputation: 29880
Class will work fine using .addClass
.
Look here: http://jsfiddle.net/TeHtz/
Upvotes: 1