我在Javascript方面相对缺乏经验,需要一些建议 . 在WooCommerce Checkout表单中,我添加了一个名为billing_countrycode的字段,该字段是国家电话代码的下拉列表 . 我希望在客户在电话号码字段中输入的电话号码之前附加此国家/地区代码 . 下面是2个字段的HTML,即国家代码下拉和电话号码字段的外观 .

<p class="form-row form-row-wide validate-required woocommerce-validated" id="billing_countrycode_field" data-priority="100">
<label for="billing_countrycode" class="">Country Code <abbr class="required" title="required">*</abbr></label>
<select name="billing_countrycode" id="billing_countrycode" class="select thwcfd-enhanced-select select2-hidden-accessible enhanced" data-placeholder="+1" tabindex="-1" aria-hidden="true">                            
<option value="+1">+1</option>
<option value="+91">+91</option>
<option value="+52">+52</option>
<option value="+44">+44</option>
<option value="+33">+33</option>
<option value="+39">+39</option>
<option value="+49">+49</option>

<p class="form-row form-row-first validate-required validate-phone" id="billing_phone_field" data-priority="110">
<label for="billing_phone" class="">Phone <abbr class="required" title="required">*</abbr></label>
<input type="tel" class="input-text " name="billing_phone" id=" autocomplete="tel"></p>