jQuery事件2-4练习
来源:2-4 编程练习
深海皮皮虾
2019-06-08 16:16:48
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>习题</title> <style type="text/css"> div { width: 200px; height: 200px; border: 1px solid red; text-align: center; line-height: 200px; } </style> </head> <body> <div>背景颜色为白色</div> <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script> <script> $(document).ready(function() { $("div").mousedown(function() { $(this).css({"background": "red"}); }) $("div").mouseup(function() { $(this).css({"background": "yellow"}); }) }) </script> </body> </html>
请老师检查
1回答
同学你好,背景颜色改变后,div元素里面的文字没有发生变化哦。
建议:使用text()方法改变内容
建议参考:
如果帮助到了你,欢迎采纳,祝学习愉快~
相似问题