在实际提出这个问题之前,我已经在这里尝试了很多解决方案,但是没有一个对我有用。
我尝试使用mounted() {
console.log(this.$moment) // undefined $moment
},
处理程序,尝试按输入名称获取,尝试onclick
,尝试getElementId
,也尝试循环访问elementClassName
,但均无济于事对我来说!
这是我的电台附加var i = 0, length = radios.length; i < length; i++
I made it short to be clean and easy to read
现在,我想获取选定的
success:function(data) { $('.shipoptions').empty(); $('.shipoptionstitle').empty(); $('.shipoptionstitle').append('<h6>Select your preferred method</h6>'); $.each(data.data, function(key, value) { $.each(value.costs, function(key2, value2) { $.each(value2.cost, function(key3, value3) { // number format var number = value3['value']; var nf = new Intl.NumberFormat('en-US', { maximumFractionDigits:0, minimumFractionDigits:0 }); var formattedNumber = nf.format(number); // number format $('.shipoptions').append('<ul class="list-form-inline"><li><label class="radio"><input type="radio" name="postchoose" data-code="'+value['code']+'" data-service="'+value2['service']+'" value="'+ value3['value'] +'"><span class="outer"><span class="inner"></span></span>'+ value['code'] + ' - ' + value2['service'] + ' - Rp ' + nf.format(number) + ' - ' + value3['etd'] +'</label></li></ul>'); }); }); }); } //success function ends here
单选按钮值,data-code
和data-service
对于临时用户,请帮助我在控制台中获取这些值,稍后我将自己修复打印部件。
有什么主意吗?
答案 0 :(得分:0)
<input type="radio" name="postchoose" data-code="'DC11'" data-service="'DS22'" value="'V33">
var dataCode = $('input[name="postchoose"]:checked').data('code');
var dataService = $('input[name="postchoose"]:checked').data('service');
var selectedVal= $("input:radio[name=postchoose]:checked").val();
答案 1 :(得分:0)
$(function() {
$(".shipoptions").on('change', function(){
var radioValue = $("input[name='postchoose']:checked");
if(radioValue){
var val = radioValue.val();
var code = radioValue.data('code');
var service = radioValue.data('service');
alert("Your are a - " + code + "- " +service+ "- " +val);
}
});
});
我需要更高级的单选按钮.shipoptions
答案 2 :(得分:0)
尝试使用此jQuery方法。
$("input[type='radio']").click(function() {
var radioValue = $("input[name='postchoose']:checked").val();
var dataCode = $("input[name='postchoose']:checked").attr('data-code');
var dataService = $("input[name='gender']:checked").attr('data-service');
console.log(dataCode);
console.log(dataService);
console.log(radioValue);
});