ID选择器:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Nearth</title> <script src="jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script> <script src="jquery-3.3.1.js" type="text/javascript" charset="utf-8"></script> <script > $(function(){ $("#btn").click(function(){ if($(this).val()=="点击我,给你惊喜······"){ $("#div1").text("这是一个有颜色的div"); $("#div1").css("backgroundColor","yellow"); $(this).val("看到惊喜没·········"); } else{ $("#div1").text("欢迎回来····"); $("#div1").css("backgroundColor","red"); $(this).val("点击我,给你惊喜······"); } }) }) </script> </head> <body> <h1>id选择器案列</h1> <hr > <input type="button" name="" id="btn" value="点击我,给你惊喜······" /> <div id="div1"> </div> </body> </html>
Nearth===>WEB前端--第8课/JQuery/id选择器小案例(变脸)
最新推荐文章于 2019-11-16 17:30:09 发布