0

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.

4

3 に答える 3

1

クラスは を使用して正常に動作し.addClassます。

ここを見てください:http://jsfiddle.net/TeHtz/

于 2012-09-25T15:21:34.930 に答える
1
$("#someID").addClass("class_name_you_want_to_add");

詳細については、http://api.jquery.com/addClass/を参照してください。

于 2012-09-25T15:21:45.177 に答える
0
$('#someID').addClass("red")

それを試してみてください

于 2012-09-25T15:21:33.887 に答える