I have a website with a simple CSS style switcher. I use the following code for a function that handles pressing two buttons of a theme, initiating a transition from dark to light and vice versa:
<script> $(function() { $(".light").click(function(){ $("link").attr("href", "css/lightHome.css"); $(".light").attr("disabled", "disabled"); $(".dark").removeAttr("disabled", "disabled") }) $(".dark").click(function(){ $("link").attr("href", "css/home.css"); $(".dark").attr("disabled", "disabled"); $(".light").removeAttr("disabled", "disabled") }) }); </script>
Everything about it works exactly the way I want, except that when I press the button, nothing happens. But second, I change the position of the cursor after clicking, then the transition occurs. I don't have a better jQuery capture, so I hope this is a simple lack of understanding of DOM processes. Perhaps due to the lack of "ready"?
I tried to click and wait a few minutes, and nothing happens until I move the cursor.
Web site:
http://watsoncn.info
javascript function jquery html css
Charles Watson
source share