Using JavaScript to open the answer container


show more Using JavaScript to open the answer container provides you with in-depth training on Web. Taught by Chris Converse as part of the Create an Expandable FAQ Listing with jQuery and Dreamweaver show less
please wait ...

Using JavaScript to open the answer container

Now we are going to complete that click event for the faq_question. So after the if statement, let's come down here, and let's type else, beginning and ending brackets. Let's split that open. So if the parent of the item that we clicked on does not have the open class, we know that the answer is closed, and we need to open it up. So the first thing we need to do is calculate how high we need to open that answer div. So let's start by creating a variable, var space newheight; that's the name of our variable.

We are going to set that equal to, dollar sign, parentheses, this inside of the parentheses, .closest, beginning and ending parentheses. Inside the parentheses two tick marks for string literal, .faq, outside of the parentheses, .find, beginning and ending parentheses, inside of the parentheses for find, tick marks for a string literal .faq_answer.

Outside of the parentheses .height, beginning and ending parentheses, space, plus, two tick marks for a string liter...

Using JavaScript to open the answer container
Video duration: 3m 59s 41m 48s Intermediate

Viewers:

Using JavaScript to open the answer container provides you with in-depth training on Web. Taught by Chris Converse as part of the Create an Expandable FAQ Listing with jQuery and Dreamweaver

Subject:
Web
Software:
Dreamweaver jQuery
Author:
please wait ...