练习题:选择器和选择好友

一、年月日选择器


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

<select id="nian" onclick="biantian()"></select>年

<select id="yue" onclick="biantian()"></select>月

<select id="tian"></select>日

<script type="text/javascript">

FillNian();

FillYue();

FillTian();

function FillNian()

{

    var b = new Date();

    var nian = parseInt(b.getFullYear());

    

    var str = "";

    

    for(var i=nian-5;i<nian+6;i++)

    {

        str = str+"<option value=‘"+i+"‘>"+i+"</option>";

    }

    

    document.getElementById("nian").innerHTML = str;

    

}

//月数

function FillYue()

{

    var str = "";

    for(var i=1;i<13;i++)

    {

        str = str+"<option value=‘"+i+"‘>"+i+"</option>";

    }

    document.getElementById("yue").innerHTML = str;

}

//每月天数的变化

function FillTian()

{

    var yue = document.getElementById("yue").value;

    var nian = document.getElementById("nian").value;

    var ts = 31;

    

    //30号的月数

    if(yue==4 || yue==6 || yue==9 || yue==11)

    {

        ts=30;

    }

    

    //2月不同年的天

    if(yue==2)

    {

        if((nian%4==0 && nian%100 != 0) || nian%400==0)

        {

            ts = 29;

        }

        else

        {

            ts = 28;

        }

    }

    

    var str = "";

    for(var i=1;i<ts+1;i++)

    {

        str = str+"<option value=‘"+i+"‘>"+i+"</option>";

    }

    document.getElementById("tian").innerHTML = str;

}

function biantian()

{

    FillTian();

}

</script>

</body>

二、选择好友


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

样式:

<style type="text/css">

*{ margin:0px auto; padding:0px}

#wai{ width:150px; height:300px;}

.list{ width:150px; height:40px; text-align:center; line-height:40px; vertical-align:middle; color:white; border:1px solid white;}

.list:hover{ cursor:pointer; padding: 0px 1em !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.8em !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; white-space: nowrap !important; background: none rgb(244, 244, 244) !important;"></style>

 

<body><br>

<div id="wai">

    <div class="list" onclick="xuan(this)" onmouseover="bian(this)" onmouseout="huifu()">淄博</div>

    <div class="list" onclick="xuan(this)" onmouseover="bian(this)" onmouseout="huifu()">张店</div>

    <div class="list" onclick="xuan(this)" onmouseover="bian(this)" onmouseout="huifu()">桓台</div>

</div>

 

</body>

 

<script type="text/javascript">

 

function xuan(d)

{

    //清原来的颜色

    var list = document.getElementsByClassName("list");

    for(var i=0;i<list.length;i++)

    {

        list[i].removeAttribute("bs");

        list[i].style.backgroundColor = "#66F";

    }

    //选

    d.setAttribute("bs",1);

    d.style.backgroundColor = "#00C";

}

 

function bian(d)

{

    //清

    var list = document.getElementsByClassName("list");

    for(var i=0;i<list.length;i++)

    {

        if(list[i].getAttribute("bs")!="1")

        {

            list[i].style.backgroundColor = "#66F";

        }

    }

    //选

    d.style.backgroundColor = "#00C";

}

 

function huifu()

{

    var list = document.getElementsByClassName("list");

    for(var i=0;i<list.length;i++)

    {

        if(list[i].getAttribute("bs")!="1")

        {

            list[i].style.backgroundColor = "#66F";

        }

    }

}

 

</script>

时间: 2024-07-28 21:42:57

练习题:选择器和选择好友的相关文章

如何在android 文件选择器中选择多个图片或者视频?

我的android app有这样的需求,在进行照片和视频上传的时候,需要一次性的从照片/视频库选择多条进行上传 但是android原生态的sdk中,只能一个一个的进行选择和上传. 我想知道是否有其他的android上传库可以解决这个问题,提供一个多选的功能,可以使checkbox之类的,一次选择多个 处理方法 官方的图片选择器(但是不支持所有版本的androi,只支持API Level >=18) http://developer.android.com/reference/android/co

jq中选择器的选择问题

<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title></title> <style type="text/css"> div{ height: 100px; width: 200px; background-color: coral; margin: 10px;} </style> <script s

TimePickerDialog时间选择器,选择0-9分钟时,显示为10:0 9:1的样式,要改成 10:00 09:01的样式 的解决方式

1 /** 2 * 设置时间选择器 3 */ 4 private void setTimePickerDialog() { 5 Calendar mCalendar = Calendar.getInstance(); 6 mCalendar.setTimeInMillis(System.currentTimeMillis()); 7 final int hour = mCalendar.get(Calendar.HOUR_OF_DAY); 8 int minute = mCalendar.get

【CSS】盒模型+选择器(你选择的要操作的对象)

盒模型 转http://www.cnblogs.com/cchyao/archive/2010/07/12/1775846.html 1.w3c标准的盒模型和ie的盒模型主要差别在于content的width和height是否包含border padding 2.标准的content是不包含border padding的 3.如何让ie也标准起来,加上<!doctype html> -------- 选择器 转http://www.cnblogs.com/yongzhi/articles/12

Jquery过滤选择器,选择前几个元素,后几个元素,内容过滤选择器等

一.基本过滤选择器(重点掌握下列八个):first 选取第一个元素 $("div:first").css("color","red");:last 选取最后一个元素 $("div:last").css("color","red");:not 除去指定的选择器外的元素 $("div:not").css("color","red")

css选择器(选择&lt;div&gt;内所有&lt;p&gt;元素)

情况1:<div><p></div> 情况2:<div><a><p></p></a></div> 使用: div p{} 其实在这里的解释是,选择<div>内所有<p>元素,不会是局限在<div>的下一级,而是不过<p>元素在第几级都会找到. 参考: http://www.w3school.com.cn/cssref/css_selectors.asp

layui-时间选择器-时间范围选择

HTML: JS: start:就为你选择的开始日期; end:就为你选择的结束日期 此方式可选择任意范围的时间,时间格式可任意修改. 原文地址:https://www.cnblogs.com/wuliMan/p/10488865.html

jQuery选择器,选择html内容时名称中有空格的解决办法

参考:https://stackoverflow.com/questions/1988483/jquery-selector-classname-with-space 今天在写nodejs爬虫,用的是cheerio,不过和jQuery基本没差别 比如要选择其中的<table>,但class名称包含空格. 一开始尝试:console.log(${".table table-sm table-bordered"}.text()).是无效的,什么也不会输出. 谷歌一通后找到了答案

python 练习题练习题2--多分支选择

题目:企业发放的奖金根据利润提成.利润(I)低于或等于10万元时,奖金可提10%:利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.5%:20万到40万之间时,高于20万元的部分,可提成5%:40万到60万之间时高于40万元的部分,可提成3%:60万到100万之间时,高于60万元的部分,可提成1.5%,高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数? 程序分析:请利用数轴来分界,定位.注意定义时需把奖金定义成