分享 原生javaScript实现的楼层导航功能

本文分享了如何利用原生JavaScript实现楼层导航功能,详细介绍了实现过程和效果展示,为网页交互增加便利。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
*{margin:0; padding:0;}
ul,ol{list-style:none;}
img {border:none;}
a {text-decoration:none;}
#container {position:relative;}
#item-1,#item-2,#item-3,#item-4,#item-5 {color:#fff; height:300px;}
#item-1 {background:#156D8E;}
#item-2 {background:red;}
#item-3 {background:green;}
#item-4 {background:blue;}
#item-5 {background:#F06;}
ul {position:fixed; right:10px; top:10px;}
ul li {color:#000; background:#fff; height:20px; margin-top:10px; cursor:pointer; border:1px solid #000;}
ul li.active {background:red; color:#fff; border:1px solid #fff;}
ul li a {line-height:20px;}
</style>
<script>

function hasClass(obj, sCls){
	
	return obj.className.match(new RegExp("\\b"+sCls+"\\b", "i"));	
		
	//match是string对象的一个方法,返回字
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值