admin 管理员组

文章数量: 1086019


2024年3月26日发(作者:springboot前端框架)

1.遍历option和添加、移除option

function changeShipMethod(shipping){

var len = $("select[@name=ISHIPTYPE] option").length

if( != "CA"){

$("select[@name=ISHIPTYPE] option").each(function(){

if($(this).val() == 111){

$(this).remove();

}

});

}else{

$("

Ground").appendTo($("select[@name=ISHIPTYPE]"));

}

}

2.取得下拉選單的選取值

$(#testSelect option:selected'').text();

或$("#testSelect").find(''option:selected'').text();

或$("#testSelect").val();

//////////////////////////////////////////////////////////////////

记 性不好的可以收藏下:

1,下拉框:

var cc1 = $(".formc select[@name=''country''] option[@selected]").text(); //得

到下拉菜单的选中项的文本(注意中间有空格)

var cc2 = $(''.formc select[@name="country"]'').val(); //得到下拉菜单的选中项的

var cc3 = $(''.formc select[@name="country"]'').attr("id"); //得到下拉菜单的选

中项的ID属性值

$("#select").empty();//清空下拉框 //$("#select").html('''');

$("").appendTo("#select")//添加下拉框的


本文标签: 添加 選單 选中 下拉菜单 下拉框