Pin CSS file to reload after jquery event

Is it possible to force a reload of a CSS file after a jquery event? i.e.

The css file has in it:

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

JQuery event:

 $('#myid').append('<td class="someclass">stuff...</td>
+5
source share
3 answers

If you are trying to add an element to the DOM, any style assigned in the STYLE block or in the attached CSS file that matches a valid style selector should automatically affect that element. You do not need to reload the attached stylesheet.

For example (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/

+2
source

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

0
source

css, javascript ( ). (: append()), css .

0
source

All Articles