Toggle() and position() method together in jQuery

Asked

Viewed 58 times

0

Can toggle() and position() methods be used on the same line of code? For example:

$("#palette-base-category-"+category).toggle("drop", 1000).position({my:"right", at:"right", of:null});

att

1 answer

1

Possible most of the time is, just do not see a use in doing this, note that the position() by definition returns an object containing the property top and left and in accordance with the documentation, it does not accept any parameter, and the toggle() simply shows or hides elements, so I could not so far find a joint use in the same line of code, if the question is not just a curiosity and you really want to do something like, expose here that maybe I can clarify more doubts, I hope it helps.

  • I have a menu, with that effect of displaying and hiding elements and what I wanted is to make those elements appear in a specific position on the right side.

  • @Fernandomessiasdasilva as I told you, with position(), you will get the current position of the elements, you may have to use some positioning CSS properties within a certain condition, type IF the menu hides the elements, of a float:right; in them, something like that...Take a look here is a response of how to position items dynamically.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.