javascript - JQuery calling the function -


I am very new to JavaScript / JQuery and I am going through a colleague's code. He has created a very common "FAQ" list on a website, where the answer is not displayed immediately, only then the question shows the answer until the user clicks on the arrow.

I'm trying to explain how it worked to get it, I understand all HTML and CSS (it looks okay), but I can not seem to understand how the jacquery will work. Or users will press the arrow on the question to answer the user. / P>

The code that is using it is down. Once again, all HTML and CSS are connected, so I think this is just a matter of using the code.

If anyone can give any help then he will be appreciated.

<("click", "div", function () {return $ (this) .next (). Toggle () .close ("li"). ToggleClass ("arrow_up") Let me annotate my code for you.

It uses some short stories which can be a little confusing for beginners.

  // Select the element with the id attribute of "faq". // When a & lt; A & gt; Which is a first-level child of a div within # #, it is clicked, perform the following action $ ("#FAQ"). ("Click", "div> a", function () {// & quot; a & gt; tag & quot; // $ (this) returns it in the cover of $ $ (this) / />  This is our & lt; p & gt; .next () // element.style.display switches between any other block. The closest parent 
  • element .closest ("li") // arrow_up Add or Remove the CSS class .toggleClass ("Arrow_up"),! 1 //! 1 is a shortcut for false}););
  • I have a complete distilled and annotated reproduction

    that also uses a shortcode for the return false . I note that their The body of the event handler is in one line. He could divide it into two rows, but he used it to fit just one.

      $ (this) .next (). Toggle (). Closest ("Lee") .toggleClass ("ARROW_UP"); return false; // false ===! 1;  

    A false event prevented the event from reaching the parent elements in the Dome after returning false from a jQuery event handler.


    Comments

    Popular posts from this blog

    sqlite3 - UPDATE a table from the SELECT of another one -

    c# - Showing a SelectedItem's Property -

    javascript - Render HTML after each iteration in loop -