分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 代码编程

Jquery操作属性选择器

发布时间:2023-09-06 01:59责任编辑:蔡小小关键词:选择器
<!DOCTYPE html><html> ???<head> ???????<meta charset="UTF-8"> ???????<title>层级选择器</title> ???????<link rel="stylesheet" href="../../css/style.css" /> ???????<script type="text/javascript" src="../../js/jquery-1.8.3.js" ></script> ???????<script> ???????????$(function(){ ???????????????$("#btn1").click(function(){ ???????????????????$("div[id]").css("background-color","red"); ???????????????}); ???????????????????????????????$("#btn2").click(function(){ ???????????????????$("div[id=‘two‘]").css("background-color","red"); ???????????????}); ???????????}); ???????</script> ???????????????????</head> ???<body> ???????<input type="button" id="btn1" value="选择有id属性的div"/> ???????<input type="button" id="btn2" value="选择有id属性的值为two的div"/> ???????????????<hr/> ???????<div id="one"> ???????????<div class="mini"> ???????????????111 ???????????</div> ???????</div> ???????????????<div id="two"> ???????????<div class="mini"> ???????????????222 ???????????</div> ???????????<div class="mini"> ???????????????333 ???????????</div> ???????</div> ???????????????<div id="three"> ???????????<div class="mini"> ???????????????444 ???????????</div> ???????????<div class="mini"> ???????????????555 ???????????</div> ???????????<div class="mini"> ???????????????666 ???????????</div> ???????</div> ???????????????<span id="four"> ???????????????????</span> ???</body></html>

style.css

body { font:12px/19px Arial, Helvetica, sans-serif; color:#666;}form div { margin:5px 0;}.int label { float:left; width:100px; text-align:right;}.int input { padding:1px 1px; border:1px solid #ccc;height:16px;}.sub { padding-left:100px;}.sub input { margin-right:10px; }.formtips{width: 200px;margin:2px;padding:2px;}.onError{ ???background:#FFE0E9 url(../img/reg3.gif) no-repeat 0 center; ???padding-left:25px;}.onSuccess{ ???background:#E9FBEB url(../img/reg4.gif) no-repeat 0 center; ???padding-left:25px;}.high{ ???color:red;} ?div,span,p { ???width:140px; ???height:140px; ???margin:5px; ???background:#aaa; ???border:#000 1px solid; ???float:left; ???font-size:17px; ???font-family:Verdana; ?} ?div.mini { ????width:55px; ???height:55px; ???background-color: #aaa; ???font-size:12px; ?} ?div.hide { ????display:none; ?}table ???????{ border:0;border-collapse:collapse;}td ???{ font:normal 12px/17px Arial;padding:2px;width:100px;}th ???????????{ font:bold 12px/17px Arial;text-align:left;padding:4px;border-bottom:1px solid #333;}.even ???????{ background:#FFF38F;} ?/* 偶数行样式*/.odd ???????{ background:#FFFFEE;} ?/* 奇数行样式*/.selected ???????{ background:#FF6500;color:#fff;}

Jquery操作属性选择器

原文地址:https://www.cnblogs.com/benjamin77/p/9162399.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved