富贵资源网 Design By www.hznty.com

效果展示:

页面初加载时:      JS实现下拉框的动态添加(附效果)


选择车类型后:      JS实现下拉框的动态添加(附效果)


选择车颜色后:     JS实现下拉框的动态添加(附效果)


JS实现下拉框的动态添加,网页代码如下
复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>动态添加下拉框</title>
<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery.js"><script type="text/javascript" src="/UploadFiles/2021-04-02/SelectMenu2.js"></head>
<body>
<form action="#">
<br />
<br />
<br />
<div class="CarInfo">

<span class="CarType">车类型:
<select >
<option value="请选择" selected="selected">请选择</option>
<option value="宝马">宝马</option>
<option value="奔驰">奔驰</option>
</select>
</span>

<span class="CarColor" style="display:none">车颜色:
<select>
</select>
</span>

<span class="CarWheel" style="display:none">车轮:
<select>
</select>
</span>
</div>
</form>
</body>
</html></SPAN>

JS代码如下
复制代码 代码如下:
// JavaScript Document
$(document).ready(function (){
var CarTypeSelect = $(".CarType").children("select");
var CarColorSelect = $(".CarColor").children("select");
var CarWheelSelect = $(".CarWheel").children("select");


//给第一个下拉框的SelectChanged时间编码
CarTypeSelect.change(function (){

//取得当前下拉框的值
var CarTypeValue = $(this).val();
//当第一个下拉框内容改变的时候,第三个下拉框要隐藏起来
CarWheelSelect.parent().hide();

if(CarTypeValue !="")
{
CarColorSelect.html("");
$("<option value = ''>请选择</option>").appendTo(CarColorSelect);
switch(CarTypeValue){

case "宝马":
var CarColor=["绿色","黑色"];
for(var i = 0;i<CarColor.length;i++){
$("<option value='"+CarColor[i]+"'>" + CarColor[i] + "</option>").appendTo(CarColorSelect);
}
break;
case "奔驰":
var CarColor = ["白色","红色"];
for(var i = 0;i<CarColor.length;i++){
$("<option value='"+CarColor[i]+"'>" + CarColor[i] + "</option>").appendTo(CarColorSelect);
}
break;
}
CarColorSelect.parent().show();
}
else
{
CarColorSelect.parent().hide();
}
});

CarColorSelect.change(function (){

var CarColorValue = $(this).val();
CarWheelSelect.html("");
if(CarColorValue != "")
{
CarWheelSelect.html("");
$("<option value = ''>请选择</option>").appendTo(CarWheelSelect);
switch(CarColorValue){

case "绿色":
var CarWheel = ["绿钢","绿碳纤维"];
for(var i = 0;i<CarWheel.length;i++){
$("<option value='"+CarWheel[i]+"'>" + CarWheel[i] + "</option>").appendTo(CarWheelSelect);
}
break;
case "红色":
var CarWheel = ["红钢","红碳纤维"];
for(var i = 0;i<CarWheel.length;i++){
$("<option value='"+CarWheel[i]+"'>" + CarWheel[i] + "</option>").appendTo(CarWheelSelect);
}
break;
case "黑色":
var CarWheel = ["黑钢","黑碳纤维"];
for(var i = 0;i<CarWheel.length;i++){
$("<option value='"+CarWheel[i]+"'>" + CarWheel[i] + "</option>").appendTo(CarWheelSelect);
}
break;
case "白色":
var CarWheel = ["白钢","白碳纤维"];
for(var i=0;i<CarWheel.length;i++){
$("<option vaiue='"+CarWheel[i]+"'>" + CarWheel[i] + "</option>").appendTo(CarWheelSelect);
}
break;
}
CarWheelSelect.parent().show();
}
else
{
CarWheelSelect.parent().hide();
}
});
});

富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。