效果

初始

点击后

参考代码

<!DOCTYPE html>
<html>
<head>
<title>Layer group example</title>
<script src="js/jquery-1.11.1.min.js"></script> <link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/bootstrap.min.js"></script> <style>
#layertree li > span {
cursor: pointer;
}
</style> <style>
ul,ol {
list-style: none
}
</style> </head>
<body> <div id="layertree" class="span6">
<span>图层列表</span>
<ul class='layer-list'>
<li><input type="checkbox"><span>Food insecurity layer</span>
<fieldset>
<input class="opacity" type="range" min="0" max="1" step="0.01"/>
</fieldset>
</li> <li><input type="checkbox"><span>World borders layer</span>
<fieldset>
<input class="opacity" type="range" min="0" max="1" step="0.01"/>
</fieldset>
</li>
</ul>
</div>
<script> $('#layertree li > span').click(function() {
$(this).siblings('fieldset').toggle();
}).siblings('fieldset').hide(); </script>
</body>
</html>

其中:

1. <html>标签<ul>表示无序列表;<ol>比奥斯有序列表

2. 以下格式,表示每一小项的前边没有默认的黑点

ul,ol {
list-style: none
}

实例

<!DOCTYPE html>
<html>
<head>
<title>Layer group example</title>
<script src="js/jquery-1.11.1.min.js"></script> <link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/bootstrap.min.js"></script> <link rel="stylesheet" href="css/ol.css" type="text/css">
<script src="js/ol.js"></script> <style>
#layertree li > span {
cursor: pointer;
}
</style>
<style>
ol,ul{
list-style:none
}
</style>
</head>
<body>
<div class="row-fluid">
<div id="map" class="map"></div> <div id="layertree" >
<span>图层列表</span>
<ul> <!--无序列表-->
<li><span>Food insecurity layer</span>
<fieldset id="layer0">
<input class="visible" type="checkbox"/>
<input class="opacity" type="range" min="0" max="1" step="0.01"/>
</fieldset>
</li> <li><span>World borders layer</span>
<fieldset id="layer1">
<input class="visible" type="checkbox"/>
<input class="opacity" type="range" min="0" max="1" step="0.01"/>
</fieldset>
</li>
</ul>
</div>
</div> <script>
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.MapQuest({layer: 'sat'})
}),
new ol.layer.Group({
layers: [
new ol.layer.Tile({
source: new ol.source.TileJSON({
url: 'http://api.tiles.mapbox.com/v3/' +
'mapbox.20110804-hoa-foodinsecurity-3month.jsonp',
crossOrigin: 'anonymous'
})
}),
new ol.layer.Tile({
source: new ol.source.TileJSON({
url: 'http://api.tiles.mapbox.com/v3/' +
'mapbox.world-borders-light.jsonp',
crossOrigin: 'anonymous'
})
})
]
})
],
target: 'map',
view: new ol.View({
center: ol.proj.fromLonLat([37.40570, 8.81566]),
zoom: 4
})
}); function bindInputs(layerid, layer) {
var visibilityInput = $(layerid + ' input.visible');
visibilityInput.on('change', function() {
layer.setVisible(this.checked);
});
visibilityInput.prop('checked', layer.getVisible()); $.each(['opacity'],
function(i, v) {
var input = $(layerid + ' input.' + v);
input.on('input change', function() {
layer.set(v, parseFloat(this.value));
});
input.val(String(layer.get(v)));
}
);
}
map.getLayers().forEach(function(layer, i) {
bindInputs('#layer' + i, layer);
if (layer instanceof ol.layer.Group) {
layer.getLayers().forEach(function(sublayer, j) {
bindInputs('#layer' + i + j, sublayer);
});
}
}); $('#layertree li > span').click(function() {
$(this).siblings('fieldset').toggle();
}).siblings('fieldset').hide(); </script>
</body>
</html>

[html/js]点击标题出现下拉列表的更多相关文章

  1. JS弹出模态窗口下拉列表特效

    效果体验:http://hovertree.com/texiao/js/20/ 或者扫描二维码在手机体验: 点击选择城市后,在弹出的层中的输入框,输入英文字母 h,会有HoverTree和Hewenq ...

  2. jquery如何实现点击标题收缩下面的内容

    jquery如何实现点击标题收缩下面的内容 一.总结 一句话总结:怎么做复杂前端任务,先把样式(最简单)做出来,然后在写js. 1.如何取jquery集合中的某个索引号的元素? 不是get(),是eq ...

  3. [WPF]ComboBox.Items为空时,点击不显示下拉列表

    ComboBox.Items为空时,点击后会显示空下拉列表: ComboBox点击显示下拉列表,大概原理为: ComboBox存在ToggleButton控件,默认ToggleButton.IsChe ...

  4. js点击左右滚动+默认自动滚动类

    js点击左右滚动+默认自动滚动类 点击下载

  5. selenium—JS点击方法

    package com.allin.pc;import java.util.NoSuchElementException;import org.openqa.selenium.By;import or ...

  6. 用 JS 点击左右按钮 使图片切换 - 最精简版-ljx2380000-ChinaUnix博客

    body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...

  7. 项目遇到的小问题(关于vue-cli中js点击事件不起作用和iconfont图片下载页面css样式乱的解答)

     第一个:关于vue-cli中js点击事件不起作用 在vue的methods方法queryBtnFun()中拼接html和click操作事件的时候,发现点击事件一起未起作用: 后来发现是DOM执行顺序 ...

  8. Js点击触发Css3的动画Animations、过渡Transitions效果

    关键是首先指定动画效果的CSS属性名称,然后在Js中改变这个属性 如果不使用Js触发,可以选择利用css的状态:hover,focus,active 来触发,也可以一开始就触发 下例为Js点击触发过渡 ...

  9. JS中点击事件冒泡阻止

    JS中点击事件冒泡阻止 解析: 一个div层'out',内含有一个div层'in'.如下: 两个层都绑定了点击事件,但是点击in层的时候,点击事件会出现冒泡现象,同时也会触发out层的点击事件. 但是 ...

随机推荐

  1. 【C#】特性标签中的属性解释

    第一个为特性作用于类,或者接口(interface) 第二个为是否允许重叠定义,就是连续写两个特性标签 第三个为是否继承,当继承时候,除输出子类外,父类也将输出

  2. Android Camera相机功能实现 拍照并保存图片

    AndroidManifest.xml <uses-feature android:name="android.hardware.camera"/> <uses- ...

  3. CENTOS7 使用 Nginx + Uwsgi 部署 Django 项目

    写在前面的话 最近总是见到有新学 Django 的朋友在部署自己的项目到 Linux 上面的时候运行不起来,所以就动手写了这篇博客. 对于不会搭建 Python 3 环境的朋友可以参考前面的博客[CE ...

  4. kali linux之主动信息收集(二层发现)

    主动信息收集: 直接与目标系统交互信息,无法避免留下访问的痕迹 使用受控的第三方电脑进行探测,如(使用代理或者使用肉鸡,做好被封杀的准备,使用噪声迷惑目标,淹没真实的探测流量) 识别活着的主机,会有潜 ...

  5. webservice怎么给对方提供报文,即wsdl文件

    1.webservice发布后在网页打开服务,点击服务说明 2.打开这样一个页面,ctrl+s保存网页,后缀改为wsdl,搞定

  6. Django 实现购物车功能

    购物车思路:使用 session 功能识别不同浏览器用户,使得用户不管是否登录了网站,均能够把想要购买的产品放在某个地方,之后随时可以显示或修改要购买的产品,等确定了之后再下订单,购物车可以用来暂存商 ...

  7. (转)VS2010实用快捷键

    1,Visual Studio 2008自带的1000多个 Windows 系统使用的各种图标.光标和动画文件在Visual Studio 2008的安装目录下,/Microsoft Visual S ...

  8. gitlab忘记管理员密码

    gitlab忘记密码后破解! gitlab-rails console production :> user = User.).first irb(main)::> user.passwo ...

  9. vue框架组件之父子组件之间的通信

    1.如图看解说: 你子标签要给我父标签传递信息,你总得有个触发机制告诉我这是怎么回事对吧  要不我怎么知道你要传数据给我呢!

  10. Docker镜像的导出和载入

    https://www.cnblogs.com/lishidefengchen/p/10564765.html