Wrapping elements and class


#1

https://www.codecademy.com/courses/web-beginner-en-v6phg/1/1

just curious if this is considered a type of wrap from text to highlighted? Kind of a bottom up wrap?



$(document).ready(function(){
   $('#text').click(function(){
       $(this).addClass('highlighted');
   });  
});



#2

Not sure I get the question. The code looks fine.


The target element is a DIV which initially has no highlighting. If we examine the style sheet we will find the selector rule for, '.highlighted'. It will look something like,

.highlighted {
    box-shadow: 0 0 8px #FFD700;
}

When we click on target, the handler is triggered that adds the class to the #text element. The browser redraws the page with the new highlight effect on that element.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.