返回 点击选中效果... 登陆

点击选中效果

幸福敲门 2019-08-07 09:01:20 264

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>选择效果</title>

<style>

li {

width: 100px;

height: 50px;

border: 1px salmon solid;

margin: 50px 30px 0px 0px;

padding: 0;

text-align: center;

line-height: 50px;

float: left;

list-style: none;

}

.active {

background: salmon;

}

</style>

</head>

<body>

<ul>

<li>1</li>

<li>1</li>

<li>1</li>

<li>1</li>

</ul>

</body>

<script src="./js/jquery-3.3.1.min.js"></script>

<script type="text/javascript">

$(function() {

$('li').click(function(){

if($(this).hasClass('active')){

$(this).removeClass('active')

}else{

$(this).addClass('active').siblings('li').removeClass('active')

}

})

})

</script>

</html>



最新手记推荐

• 用composer安装thinkphp框架的步骤 • 省市区接口说明 • 用thinkphp,后台新增栏目 • 管理员添加编辑删除 • 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消 回复 发送
  • PHP中文网