5

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>
3
  • 2
    What is your current problem? What do you want to achieve with this reloading? Commented Jul 21, 2011 at 23:35
  • 2
    why would you want to reload your css if it hasn't changed. Commented Jul 21, 2011 at 23:36
  • if you want the td element you're appending to have the someclass class after you append it, it will. you don't need to reload your CSS file Commented Jul 21, 2011 at 23:37

3 Answers 3

2

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/

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

-1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.