欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
jQuery Select Change Event, Get Selected Option | FormGet

If you have two select fields and want to load options in second one, based on selected option from first one then, below example will help you lot to understand how it can be done.

Here in this example, when a user selects country in first select field, jQuery on change event is called upon to list out it’s relevant cities in second select field simultaneously.

Given below jQuery select change function’s syntax:  

$("select").change(function(){// Do something here.}

we used arrays to store city names for different countries and created a function city(arr) which populates options (city names relevant to selected country) for second select tag as shown below:

//Function To List out Cities in Second Select tagsfunction city(arr){$("#city").empty();//To reset cities$("#city").append("<option>--Select--</option>");$(arr).each(function(i){//to list cities$("#city").append("<option value=""+arr[i].value+"">"+arr[i].display+"</option>")});}

Watch our live demo or download code to use it.

To learn more, our Complete HTML and jQuery Code is given below:

HTML File: select_jquery.html

Given below our complete HTML code , copy to use it.

<!DOCTYPE html><html><head><title>jQuery Select Change Event For Dependent Select Option Field - Demo Preview</title><meta name="robots" content="noindex, nofollow"><!-- Include CSS File Here --><link rel="stylesheet" href="select_jquery.css"/><!-- Include JS File Here --><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><script type="text/javascript" src="select_jquery.js"></script></head><body><div class="container"><div class="main"><h2>Dependent Select Option Field Example</h2><label>Select Country:</label><div id="prm"><select id="country"><option>--Select--</option><option>USA</option><option>AUSTRALIA</option><option>FRANCE</option></select><label>Select City:</label><select id="city"><!-- Dependent Select option field --></select></div></div></div></body></html>

jQuery File: select_jquery.js

Given below our complete jQuery code for initializing second select tag options.

$(document).ready(function() {// Initializing arrays with city names.var USA = [{display: "Washington, D.C.",value: "WashingtonDC"},{display: "Alaska", value: "Alaska"},{display: "New York",value: "New-York"},{display: "Florida",value: "Florida"},{display: "Hawaii",value: "Hawaii"},{display: "California",value: "California"}];var AUSTRALIA = [{display: "Canberra",value: "Canberra"},{display: "Sydney",value: "Sydney"},{display: "Melbourne",value: "Melbourne"},{display: "Perth",value: "Perth"},{display: "Gold Coast ",value: "Gold-Coast"}];var FRANCE = [{display: "Paris",value: "Paris"},{display: "Avignon",value: "Avignon"},{ display: "Strasbourg",value: "Strasbourg"},{display: "Nice", value: "Nice"}];// Function executes on change of first select option field.$("#country").change(function() {var select = $("#country option:selected").val();switch (select) {case "USA":city(USA);break;case "AUSTRALIA":city(AUSTRALIA);break;case "FRANCE":city(FRANCE);break;default:$("#city").empty();$("#city").append("<option>--Select--</option>");break;}});// Function To List out Cities in Second Select tagsfunction city(arr) {$("#city").empty(); //To reset cities$("#city").append("<option>--Select--</option>");$(arr).each(function(i) { //to list cities$("#city").append("<option value=\"" + arr[i].value + "\">" + arr[i].display + "</option>")});}});

CSS File: select_jquery.css

Styling HTML Elements.

/* Below line is used for online Google font */@import url(http://fonts.googleapis.com/css?family=Droid+Serif);h2{text-align: center;}div.container{width: 960px;height: 610px;margin:50px auto;font-family: 'Droid Serif', serif;position:relative;}div.main{width: 320px;float:left;padding: 10px 60px 40px;box-shadow: 0 0 10px;border-radius: 2px;font-size: 13px;margin-top: 70px;}label{color: #464646;text-shadow: 0 1px 0 #fff;font-size: 14px;font-weight: bold;}select#country,#city{width:100%;height:30px;font-size:16px;font-family:cursive;}select#USA,select#AUSTRALIA,select#FRANCE{display:none;width:100%;height:30px;font-size:16px;font-family:cursive;}

Conclusion:

This was all about to use select change event for populating list in second select tag.  Hope you like it, Keep reading our other blogs.

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
jQuery文件樹(shù)形結構菜單插件
在線(xiàn)翻譯代碼
用純css改變下拉列表select框的默認樣式
二級聯(lián)動(dòng)下拉框
動(dòng)態(tài)生成select選項全接觸
jQuery自定義元素右鍵點(diǎn)擊事件
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久