gpt4 book ai didi

javascript - 为导航栏上的选项卡使用 switch case

转载 作者:行者123 更新时间:2023-11-28 02:33:38 25 4
gpt4 key购买 nike

我想使用 switch case 仅在某些选项卡上显示某些功能。我有一个位于我的 html 中的 basemap 切换开关,我想通过在 css 中将其显示为 none 来关闭我的最后一个选项卡。有什么建议么?我已经为导航栏中每个选项卡上的工具提示设置了一个开关盒。它看起来像这样:

let tabs = $('.entries > .nav > .entry > .entryLbl ');
tabs.each(function (idx, liItem) {
switch (liItem.text) {
case 'Electric':
//liItem.on('click', function () {
// console.log('got a click on electric');
//});
liItem.setAttribute('title', 'To download a Los Angeles Substructure Plan: \n 1. Zoom to a substructure quad\n 2. Click the area inside the quad \n 3. Click "More info"');
document.getElementById('BasemapToggle').style.display="none"
break;
case 'Gas/Oil':
liItem.setAttribute('title', 'This tab contains non-hazardous gas/oil utilities. Visit our confidential \n gas/oil application at: http://sv07gis6/undergroundconfidential');
break;
case 'Sanitation':
liItem.setAttribute('title', 'Download LA City SanGIS Data in its entirety at:\n http://geohub.lacity.org/datasets?q=sewer \nDownload LACSD GIS Data in its entirety at:\n http://data-lacsdgis.opendata.arcgis.com');
break;
case 'Stormwater':
liItem.setAttribute('title', 'Download LA County Stormwater GIS Data in its entirety at: \n http://dpw.lacounty.gov/fcd/stormdrain/disclaimer.cfm \n and click "File Geodatabase Download"');
break;
case 'Download':
liItem.setAttribute('title', 'Use this tab to download snippets of all utility types within\n up to a 500-foot range in .shp or .dgn formats');
break;
case 'Resources':
liItem.setAttribute('title', 'Please contact D7GIS to help with our resources list');
break;
}
})
});

非常感谢,布兰登

最佳答案

直接使用 css 定位最后一个 li(假设您正在为导航使用 ul/li 结构)

.entries > .nav > li:last-of-type {
display: none;
}

关于javascript - 为导航栏上的选项卡使用 switch case,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47560379/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com