raju raju - 8 months ago 39
AngularJS Question

How to remove hover effect for some of the cells in angularjs

I am using angularjs and following is my css

table {
border: 1px solid black;
padding: 0.5em;

td {
padding: 1em;
border: 2px solid gray;

td:hover {
cursor: default;
background-color: gray;

.active {
border: 2px solid lightgreen;
border-radius: 5px;

.booked {
background-color: lightgray;

.no_seat {
padding: 0em;
border: 2px white;
background-color: white;

.filled {
background-color: teal;

I want to remove td:hover effect if it is no_seat I removed the border for the cells if no_seat by resetting padding and border but dont know how to remove the hover effect.

following is my index.html

<div ng-app="bookYourSeatApp" ng-controller="mainCtrl as ctrl">
<label>Persons <select ng-model="ctrl.selectedCount" ng-change="ctrl.seats.setAvailCount(ctrl.selectedCount)" ng-options="count as count.val for count in ctrl.selectionCount"></select></label>
Seats left: {{ctrl.seats.availCount}}<br/>
Seats selected: {{ctrl.seats.checkedSeats}}<br/>
<table ng-repeat="(key, rang) in ctrl.seats.map">
<tr ng-repeat="row in rang.seats">
<td ng-repeat="seat in row" ng-class="{'active': seat.checked, 'booked': seat.status == 'UNAVAILABLE', 'no_seat': seat.status == 'NO_SEAT', 'filled': seat.status == 'FILLED'}" ng-click="ctrl.seats.select({rang:key, row:row, seat: seat}, ctrl.selectedCount)">


You are looking for the :not pseudo-class.

The negation CSS pseudo-class, :not(X), is a functional notation taking a simple selector X as an argument. It matches an element that is not represented by the argument. X must not contain another negation selector.

Change this:

td:hover {
    cursor: default;
    background-color: gray;

To this:

td:not(.no_seat):hover {
 cursor: default;
 background-color: gray;