Article
Change div background color on click
https://cdn.jsdelivr.net/npm/[email protected]/dist/js.cookie.min.js
Copy to clipboard
The click() function works on all other types of elements. Here is an example of the click function changing the background color of our gray area div. https://raw.githubusercontent.com/finsweet/jqueryCourse/main/jquery%20events/ex7.js?actionable=true
<script>
$(document).ready(function(){
XT1
});
</script>
$(document).ready(function(){
XT1
});
</script>
Copy to clipboard
Live demo
<style>.pop-up{background-color:#5d6373; padding: 1rem;}</style><div id="minidivpage" class="example-live"><div id="popUp" class="pop-up">Gray Area</div><a id="alertButton" href="#" class="w-button">Button alert</a></div>
<script>
$(document).ready(function() {
XT1
});
</script>
$(document).ready(function() {
XT1
});
</script>
Copy to clipboard
Press the Run Demo button to execute the scripts above.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.