How do I change any CSS properties during runtime?
Suppose I have:
#mycss {
background:#000;
padding:0;
}
Then during runtime, #mycss should be:
#mycss {
background:#fff;
padding:10px;
}
————————**EDIT***——————————————-
Im sorry guys, I’m really new to the HTML world…
My problem or question, whatever that is, I would like to create a piece of code that would change current CSS properties by simply putting a value on the input box (e.g. color: #fff or white) and when I hit the button, it would change the current CSS background color from the default color (#000) to user-defined color (e.g. #fff).
You could change it any of the following ways:
Additional Style Solution:
Inline Style Solution:
Add the following
style='background: #fff; padding: 10px'to your element withid='mycss'jQuery Solution (obviously requires you to include jQuery):
————————————————————Edit—————————————————————–
Using jQuery – I believe I achieved the functionality you were looking for in your edit. It could be accomplished in pure javascript as well, just let me know if you would like that solution, here is a demo.
Type any color and change the background (Red, #F7F6F5, Purple, #999 etc.)