BentCoder
BentCoder

Reputation: 12740

dropdown menu width to be changed to dynamic

In this example, width is fixed for "My Account" text. What I want to do is to make it dynamic so it should either widen or shrink based on length of the text because, instead of writing "My Account", I'll print full name of user and will always be different.

Menu goes out of current place, When I change position and width values.

Example

If there is simpler example you know, please let me know.

Thanks

Upvotes: 1

Views: 1092

Answers (1)

Eric Goncalves
Eric Goncalves

Reputation: 5353

You need to delete all styles that give the drop down a set width, and add $('.submenu').width($('.account').outerWidth()); when the page loads.

jsFiddle: http://jsfiddle.net/fRGqD/1/

Upvotes: 2

Related Questions