I would 开发者_如何学JAVAlike to know that is there anyway to make changes in .css file using Jquery or javascript. I know, I can dynamically add css properties(or classes) to DOM Element but I don't want that! I want to make changes in .css file to customize css class of .css file.
Please let me know that, is there any easy way for this. Thanks in Advance..!
Nope, you can't. You can override the css values with inline one. Because of *.css
files are static and placed on the server - you can't bring any changes to the server css file. The only way - use server side of the application (PHP, ASP.NET, etc)
I Don't think there is any easy way for what are you looking for..!!
Not really.
There's some ActiveX stuff in IE that lets you modify things in the file system but aside from not being a recomended solution, they'd only work in IE anyway.
You can still modify the styles your page uses for selectors in your css files, but you won't actually be modifying the css file itself.
You can't physically change the contents of a file using Javascript in a browser. That's for security reasons, so that content on a web page can't manipulate content on your computer (apart from cookies).
You cannot do it directly within jQuery, but you can load the .css file with jQuery, edit the contents and then send the data to a php or asp.net page which overrides the .css file with the new contents. But this is very dangerous because people can exploit the code and save any data in that .css file unless you have some security procedure but I can't think of any way you can make that work safely.
You can rather have different css files written based on your requirement then change css file using click event which will eventually change the look of ur webpage or a part of your webpage. Here is the solution. http://www.jquery4u.com/dynamic-css-2/jquery-change-css-file-2/
You could generate the CSS server-side and display inline (in the head). That would allow you to serve up styles on a per-user basis.
精彩评论