【发布时间】:2015-04-04 13:51:05
【问题描述】:
我想在选择单选按钮时隐藏 div。
<div class="col-md-3">
<input type="radio" name="service_option" ng-model="service_option" value="adhoc" id="service_option">Adhoc <br/>
<input type="radio" name="service_option" ng-model="service_option" value="weekly" id="service_option">Weekly
<div class="product-noselected-message" style="font-size: 10px; color: red">Please choose an option</div>
</div>
<div class="col-md-3">
<button class="btn btn-default" ng-click="getReservationDetails('lg', packageSlot)"> Book Now </button>
</div>
在我的代码中,如果选择了单选按钮,我希望隐藏 div class= product-noselected-message。
这是我目前在我的 javascript 上的内容
$scope.getReservationDetails = function(size, packageSlot) {
var service_option;
if($('input[name=service_option]:checked')) {
service_option = $('input[name=service_option]:checked').val();
}
if (service_option!= null) {
$rootScope.date = new Date();
console.log($rootScope.date);
$rootScope.singlePackageSlot = packageSlot;
$rootScope.locationName = $scope.cleaningServiceLocation.name;
modalInstance = $modal.open({
templateUrl: 'views/cleaning_services/register_event.html',
controller: 'CleaningServicesCancelCtrl',
size: size
});
}
else {
$('.product-noselected-message').html('Please select an option');
}
$('#service_option').on('checked', function() {
$('.product-noselected-message').addClass('hidden');
});
但它不起作用我该怎么办?
【问题讨论】:
-
添加了 bootstrap 作为标签,因为 Kingsley Simon 不想添加它,但预计其中一位回答者会猜到。
标签: javascript jquery angularjs twitter-bootstrap