Can jQuery change css style definition? (not individual css of each element)

后端 未结 4 1600
挽巷
挽巷 2020-11-29 04:23

I haven\'t seen any docs saying jQuery can change any CSS definition such as changing

td { padding: 0.2em 1.2em }

to

td {          


        
4条回答
  •  误落风尘
    2020-11-29 05:16

    Nope, it just doesn't work this way...not sure any better way to explain it than that :)

    jQuery was designed to work on elements...if you're doing this for testing, Firebug of the Chrome console are options though.

    Something you could do, is have a server-side generated stylesheet, for example how ThemeRoller does it, and jQuery (or vanilla JS) dynamically adds that into your header, something like:

     
    

    If it was the last link, it'd override the previously defined style...in fact this is exactly how ThemeRoller works.

提交回复
热议问题