0

i have chosen some of div elements in HTML and save them in an array

var Div = $(".etc") ;

i want to use this notation to slide-toggle Div elements with this code ;

Div[0].slideToggle(...) ;

but it doesn't work and doesn't toggle the element . although i try to alert element's value or name and other attributes but it doesn't work.

3 Answers 3

4

The bracket notation returns DOM elements, which do not have a slideToggle method. What you want is .eq, which filters in the same manner but returns jQuery objects instead:

Div.eq(0).slideToggle(...) ;
Sign up to request clarification or add additional context in comments.

Comments

3

Use eq():

Div.eq(0).slideToggle(...);

Comments

2

Try:

$(Div[0]).slideToggle(...) ;

Or:

Div.eq(0).slideToggle(...) ;

.eq()

1 Comment

it is better to use .eq() as you already have a jquery object

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.