开发者

Force CSS file to reload after jquery event

Is it possible to force the CSS file to reload after a j开发者_如何学Goquery event? i.e.

css file has in it:

 .someclass{
 font-size:2em;
 font-family:courier;
 etc...
 }

Jquery event(s):

 $('#myid').append('<td class="someclass">stuff...</td>


If you're trying to add an element to the DOM, any style designated in a STYLE block or in an attached CSS file that is matched by a valid stylesheet selector should automatically affect that element. You do not need to reload the attached stylesheet.

For instance (demo):

.someclass {
    background-color: #f00;
    padding: 5px;
}

<table id="myid">
    <tbody>
        <tr>
            <td>Adjacent to added TD</td>
        </tr>
    </tbody>
</table>

$('#myid tbody tr').append('<td class="someclass">stuff...</td>');

http://jsfiddle.net/5WLnX/


If you are not changing your css file, you should not force a javascript reload of it (if that is possible even). when you create new elements (ex: with append()) all css is applied to it automatically.


It is automatically applied on your <td>, there is no need to reload it or so...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜