简体   繁体   English

第三方JS默认选择国家

[英]Default selection of country by a 3rd party JS

I have one query: 我有一个查询:

Currently user need to select one country then the states of that country are coming in state field automatically. 当前用户需要选择一个国家,然后该国家的州自动进入州字段。 But I want united state selected by default with its states in the state field. 但我希望默认情况下在状态字段中选择其状态的united state How can I do this: Below is my code.....what parameters to pass 我该怎么做:以下是我的代码.....要传递的参数

ll(document).ready(function() {
ll("#country").change(function(){
    ChangeCountryAndStateLabel({
       'obj'       : this,
       'targetObj' : '#state_cus1',
       'sel'       : '',
       'id'        : 'fields_state'
    },{
       'obj'       : this,
       'targetObj' : '#fields_state_region',
       'template'  : '<LABEL>'
    });


});

You can do that like; 你可以那样做;

HTML: HTML:

<select id="select">
    <option value="utah">Utah</option>
    <option value="united-states">united states</option>
</select>

JS: JS:

$(document).ready(function(){
    $("#select").val("united-states");
})

You can use this after your code. 您可以在代码后使用它。 Only this part: 仅此部分:

$("#select").val("united-states");

See working fiddle here: http://jsfiddle.net/3Dkfe/ 在这里查看工作小提琴: http : //jsfiddle.net/3Dkfe/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM