Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force CSS file to reload after jquery event

Tags:

jquery

css

Is it possible to force the CSS file to reload after a jquery 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>
like image 547
Clay Smith Avatar asked Nov 05 '22 17:11

Clay Smith


1 Answers

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/

like image 189
Jared Farrish Avatar answered Nov 15 '22 00:11

Jared Farrish