源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

JQuery里面的几种选择器 查找满足条件的元素$("#控件ID")

  • 时间:2020-08-15 14:41 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:JQuery里面的几种选择器 查找满足条件的元素$("#控件ID")
样式:$(function (){ $("要选择的标签").click(function (){alert ("弹出对话框内容");}) }); 第一种:Id选择器 用法:
[u]复制代码[/u] 代码如下:
<head> <title></title> <script src ="Jq/jquery-1.4.2.js" type ="text/javascript" ></script> <script type ="text/javascript"> $(function (){ $("p").click(function (){alert ("小P");}) }); </script> </head> <body> <input type="button" value ="PlayGame" id="btnClick" /> <p>第一个</p> <p>第二个</p> </body>
说明:对所有<P>标签点击都有弹出对话框的提示 第二种:CSS选择器
[u]复制代码[/u] 代码如下:
<head> <title></title> <script src ="Jq/jquery-1.4.2.js" type ="text/javascript" ></script> <script type ="text/javascript"> $(function (){ $(".warning").click(function (){alert("这是警告信息");}); }); </script> <style type="text/css" > .warning{background-color :Yellow ;color :Red ;} </style> </head> <body> <p>没有警告</p> <div class ="warning " >请带好小孩</div> <p class ="warning ">再次警告你</p> <input class ="warning " type ="button" value ="别点啊" /> </body>
说明:对所有CSS样式为:.warning点击都有弹出对话框的提示 第三种:多条件选择器
[u]复制代码[/u] 代码如下:
<head> <title></title> <script src ="Jq/jquery-1.4.2.js"></script> <script type ="text/javascript" > $(function (){ $(".docc,p,#txt1").click(function (){alert ("不要上当啊");}) }) </script> <style type="text/css" > .docc{background-color :Fuchsia ;color :Olive ;} </style> </head> <body> <p>电脑热卖</p> <input type ="text" id="txt1" /> <input class ="docc" type ="button" value ="上当" /> <input type ="checkbox" /> </body>
说明:可以对多个同时选中做处理。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部