7. The o shortcut


#1

Hi, please what is wrong with my code?

I have also noticed that in the html file, the div class isnt "description" as the exercise states, but is "description row". Shouldnt it be the same as the class we are using on the jquery?

var main = function(){
$('.article').click(function() {
$('.article).removeClass('current');
$('.description').hide();

$(this).addClass('current');
$(this).children('.description').show();

});
$(document).keypress(function(event){
if(event.which === 111){
$('.current').children('.description').toggle();
}
});
}
$(document).ready(main);


#2

Hi

you forgot the closing ' after .article :slightly_smiling: When corrected, your code works for me


#3

THANK YOU VERY MUCH.

Can you explain me one last thing?

Why in the app.js file we'are using '.description', but when you go to the index.html, there is //"<" div class="description row" ">"//

Isnt that wrong? the name of the class is "description row", why in the app.js we are using "description" and not "description row"

thanks


#4

@javasolver78549 description row is actually two classes.
In an array (or list, in some languages), the separator is a comma (,):

               // ↓ second item; the comma means it's a new thing
var foo = ["one", "two", "three"]
        // ↑ first item  ↑ third item

In the class attribute on an HTML, a space is what creates a new class. So,

<div class="description row">
  <!-- ... -->
</div>

That <div> has two classes:

  1. description
  2. row

And you can select it by either class.
Does this help? :slightly_smiling:


#5

Yes, helped a lot, thank you for your time.