what does it mean for the following line?
T = ($("#a .b").hasClass("active") ? "C" : "D") ;
$("#a .b").hasClass("active") means whether #a .b exists? but how about ? "C" : "D", is it some kind of comparison logic?
what does it mean for the following line?
T = ($("#a .b").hasClass("active") ? "C" : "D") ;
$("#a .b").hasClass("active") means whether #a .b exists? but how about ? "C" : "D", is it some kind of comparison logic?
It's a ternary operator
condition ? expr1 : expr2
If condition is true then expr1 would return else expr2 will return.
So, in your case:
T = ($("#a .b").hasClass("active") ? "C" : "D") ;
T variable will hold "C" if $("#a .b") has class active else it would hold "D"
It tell you that :
if ( $("#a .b").hasClass("active") ) {
T = "C";
} else {
T = "D"
}
Here you can read this doc for further understanding. Ternary Operator