html5 - Can HTML or JS dynamically change .css attributes?
伊谢尔伦
伊谢尔伦 2017-05-24 11:36:09
0
2
951

For example, is it possible to change the attribute value of *.css or <style> based on the input value content?
For example: use the input:color tag to get the selected color value and update the color of the scroll bar? (This must use a selector, not inline)


One method that comes to mind right now is to use js to create a <style> on the current page, and then modify the content in this tag. Wondering if you have any other ideas?


It feels like I didn’t describe it clearly. The attribute value of the css style sheet needs to be given according to the value. For example: if the user selects #6ec42a, then the scroll bar becomes the color #6ec42a. In this case, it is not easy to prepare CSS files in advance. Can't we exhaust all hexadecimal colors and make different CSS files? But I am very grateful for the method you just shared. I don’t know this either, so I just learned it!

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
黄舟

Write several .css files with different plans, and use js to dynamically load the css files according to the situation

phpcn_u1582

For example, is it possible to change the attribute value of *.css or <style> based on the input value content?
You can replace *.css with attribute selector
For example: $("[href*=aaa.css]").attr({href: 'bbb.css'});

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template