我的代码:
<script type="text/javascript">
$(document).ready(function () {
$('#<%= chkCheckedSame.ClientID %>').change(function () {
if (document.getElementById('<%=chkCheckedSame.ClientID %>').checked) {
$('#<%=ShippingFirstName.ClientID %>').val
($('#<%=BillingFirstName.ClientID %>').val()); //working
$('#<%=ShippingLastName.ClientID %>').val
($('#<%=BillingLastName.ClientID %>').val());//working
alert($('#<%=BillingCountry.ClientID %>').val());
$('#<%=ShippingCountry.ClientID %> :selected').val
($('#<%=BillingCountry.ClientID %> :selected').val()); //Notworking
}
else {
}
});
});
</script>
我的尝试:
Try1:
$('#<%=ShippingCountry.ClientID %> :selected').val
($('#<%=BillingCountry.ClientID %> :selected').val());
Try2:
$('#<%=ShippingCountry.ClientID %> :selected').text
($('#<%=BillingCountry.ClientID %> :selected').text());
Try3:
$('#<%=ShippingCountry.ClientID %>').val
($('#<%=BillingCountry.ClientID %>').val());
答案 0 :(得分:1)
您需要使用选中的选项。
选项值
($('#<%=BillingCountry.ClientID %> option:selected').val());
选项
的文字 $('#<%=BillingCountry.ClientID %> option:selected').text();
您可能还有其他东西阻止了所需的输出,例如
$('#<%=ShippingFirstName.ClientID %>').val
将是语法错误。 $('#<%=ShippingFirstName.ClientID %>').val
应为$('#<%=ShippingFirstName.ClientID %>').val();