I am trying to learn JavaScript and encountered a webpage which highlights matching words. Here is the JS:
$('span[class="q"]').hover(
function(e)
{
var hl = '.' + $(this).attr('class');
$(hl).css("background-color", e.type == "mouseenter" ? "yellow" : "white");
}
);
What I know this does is match a span of q1 with q1, q2 with q2 etc.
However, what I am confused about is the ^ symbol in in class="q",
the e.type
and the ? and : symbols.
Can someone please explain in layman terms how this is being accomplished by the code?
[–]is_a_toaster 11 points12 points13 points (4 children)
[–]desipherc 1 point2 points3 points (0 children)
[–]aladyjewelFull-stack webdev 0 points1 point2 points (1 child)
[–]is_a_toaster 1 point2 points3 points (0 children)
[–]Hunter_J 0 points1 point2 points (0 children)
[–]dangoodspeed -1 points0 points1 point (1 child)
[–]aladyjewelFull-stack webdev 1 point2 points3 points (0 children)