效果

初始

点击后

参考代码

<!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. DataGridView自定义行样式和行标题

    定义两个样式对象: //定义两种行样式 private DataGridViewCellStyle m_RowStyleNormal; private DataGridViewCellStyle m_ ...

  2. SurfaceView和SurfaceHolder的基本用法

    仅做记录使用,新手也可以来看看,怎么得到一个surfaceholder. 1.在xml文件中增加一个surfaceView控件. <SurfaceView android:layout_widt ...

  3. Android学习笔记 TextSwitcher文本切换组件的使用

    activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android&qu ...

  4. 在成员函数中调用虚函数(关于多态的注意事项)------新标准c++程序设计

    类的成员函数之间可以互相调用.在成员函数(静态成员函数.构造函数和析构函数除外)中调用其他虚成员函数的语句是多态的.例如: #include<iostream> using namespa ...

  5. 洛谷P4724 【模板】三维凸包

    题面 传送门 题解 先理一下关于立体几何的基本芝士好了--顺便全都是从\(xzy\)巨巨的博客上抄来的 加减 三维向量加减和二维向量一样 模长 \(|a|=\sqrt{x^2+y^2+z^2}\) 点 ...

  6. 堆排序工具类(适用于top k问题,java泛型实现)

    代码如下,作用如标题所述 public class HeapSort { //方法作用:取出list里面的最小的 k 个值 public static <T extends Comparable ...

  7. [Swift实际操作]八、实用进阶-(10)使用Swift创建一个二叉树BinaryTreeNode

    1.二叉树的特点: (1).每个节点最多有两个子树(2).左子树和右子树是有顺序的,次序不能颠倒(3).即使某节点只有一个子树,也要区分左右子树 2.二叉查找树(Binary Search Tree) ...

  8. HDU-1754-I Hate It(线段树 单点更新 区间最大值)

    I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  9. 解决vs code中golang插件依赖安装失败问题

    解决vs code中golang插件依赖安装失败问题 Installing github.com/nsf/gocode SUCCEEDED Installing github.com/uudashr/ ...

  10. css3之animation制作闪烁文字效果 转

    原文 http://www.w3cfuns.com/notes/13835/596cd96f59a09431a2343a9726c295d5.html <!DOCTYPE html>< ...