例题二、用div做下拉列表

<title>无标题文档</title>
<style type="text/css">
*{ margin:0px auto; padding:0px}
#xiala{ width:180px; height:33px; border:1px solid #999;text-align:center; line-height:33px; vertical-align:middle; }
#xiala:hover{ cursor:pointer} #zi{width:180px; height:150px; border:1px solid #63C; border-top:0px; display:none} .list{width:180px; height:33px; text-align:center; line-height:33px; vertical-align:middle; border-bottom:1px solid #63C; background-color:#CCC}
.list:hover{ cursor:pointer; background-color:#63C; color:white} </style> </head> <body> <div style="width:700px; height:500px; margin-top:30px">   <div id="xiala" onclick="Show()"></div>
  <div id="zi">
    <div class="list" onclick="Xuan(this)">山东</div>//this表示一个元素这个元素相当于它本身。this写在哪一行里,就相当于这一行本身。
    <div class="list" onclick="Xuan(this)">淄博</div>
    <div class="list" onclick="Xuan(this)">张店</div>
  </div>
</div> </body>
<script type="text/javascript">
function Show()
{
  document.getElementById("zi").style.display="block";
}
function Xuan(ys)//ys代表选中的元素(山东、淄博、张店所在的div)
{
  var v = ys.innerText;
  document.getElementById("xiala").innerText = v;
  document.getElementById("zi").style.display="none";
}
</script>

9月23日JavaScript作业----用DIV做下拉列表的更多相关文章

  1. 9月23日JavaScript作业----日期时间选择

    作业二:日期时间选择 <div style="width:600px; height:100px;"> <select id="year"&g ...

  2. 9月23日JavaScript作业----子菜单下拉

    例题一.子菜单下拉 <style type="text/css"> *{ margin:0px auto; padding:0px} #menu{ width:700p ...

  3. 9月23日JavaScript作业----两个列表之间移动数据

    作业一:两个列表之间数据从一个列表移动到另一个列表 <div style="width:600px; height:500px; margin-top:20px"> & ...

  4. 5月23日 JavaScript

    一.JavaScript简介 1.JavaScript是什么: 它是个脚本语言,需要有宿主文件,它的宿主文件是HTML文件. 2.它的用法: 在HTML中位置有三块: (1)head里面 (2)bod ...

  5. 5月23日 JavaScript练习:累加求和

    第一种方法: 第二种方法:

  6. Week16(12月23日):复习

    Part I:提问 =========================== 1.声明强类型视图时,使用关键字(    ) A.ViewBag    B.model    C.Type    D.Tit ...

  7. 2016年12月23日 星期五 --出埃及记 Exodus 21:18

    2016年12月23日 星期五 --出埃及记 Exodus 21:18 "If men quarrel and one hits the other with a stone or with ...

  8. [分享] 从定制Win7母盘到封装详细教程 By BILL ( 10月23日补充说明 )

    [分享] 从定制Win7母盘到封装详细教程 By BILL ( 10月23日补充说明 ) billcheung 发表于 2011-10-23 00:07:49 https://www.itsk.com ...

  9. 11月23日《奥威Power-BI报表集成到其他系统》腾讯课堂开课啦

    听说明天全国各地区都要冷到爆了,要是天气冷到可以放假就好了.想象一下大冷天的一定要在被窝里度过才对嘛,索性明天晚上来个相约吧,相约在被窝里看奥威Power-BI公开课如何?        上周奥威公开 ...

随机推荐

  1. 写启动界面Splash的正确姿势,解决启动白屏(转)

    原文链接:http://www.jianshu.com/p/cd6ef8d3d74d 从我学习写第一个android项目以来,我都是这样写着启动界面: 在里面做一些事,比如:第一次启动时拷贝数据. 然 ...

  2. Andriod ADB开启Activity、Service以及BroadCast(包括参数的传递)

    /*****************开启Activity  并传递参数*******************/ 使用am命令启动Activity并传递参数的方法,也能用作C层与Java进行数据传递的一 ...

  3. 10 函数的复写-override

    1.函数的复写:override 2.使用super调用父类的成员函数 class Person { String name; int age; void introduce() { System.o ...

  4. shell 题

    (1)有一推主机地址:a.baidu.com.....z.baidu.com如何从这些数据中提取出.baidu.com之前的字母,如:a b...z? #cat f1.txt | while read ...

  5. OPENGL的入门第一个程序——Hello World

    #include "stdafx.h" #include<GL\glut.h> void Init() { glClearColor(0.0f,0.0f,0.0f,0. ...

  6. Leetcode Wiggle Sort II

    Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]... ...

  7. 【BZOJ-3712】Fiolki LCA + 倍增 (idea题)

    3712: [PA2014]Fiolki Time Limit: 30 Sec  Memory Limit: 128 MBSubmit: 303  Solved: 67[Submit][Status] ...

  8. springMVC-JSR303数据效验

    JSR 303 是java为Bean数据合法性校验提供的标准框架, 它已经包含在javaEE6.0中 JSR 303 通过Bean属性上标注类似于@NotNull.@Max等标准的注解指定校验规则, ...

  9. codeforces 723C : Polycarp at the Radio

    Description Polycarp is a music editor at the radio station. He received a playlist for tomorrow, th ...

  10. 遍历map集合

    for(var key in map){ if(data.hasOwnProperty(key)){ var value = map[key]; } }​