jQuery .show() function question

Here is a code snippet I got from jQuery's website at http://api.jquery.com/show/. The show() function clearly animates by expanding the width, height, and opacity in a certain way. Is there a way to alter that? For example, what if I wanted only the height to expand and not the width, or vice versa?

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

How can you have height without width when the element is 100% wide?
If you don't want 100% width then use inline-block in the css or use an inline element.

elepilAuthor Commented: 2014-11-29

You can set the width and height (or line-height) to a fixed pixel value prior.

You didn't answer my question though. Is there a way to alter the way jQuery handles it's show()/hide() animation in terms of how it manipulates the properties? (Aside from going into the jQuery code and modifying it there, of course.)

Gary, I think you're missing my point. I'm not trying to make an animation with the width preset and the height expanding downward; that was just an animation variant example I gave to stress the point that jQuery's animation choreography may not be what I want. You used the animate() function, which wasn't even what I was asking about.

The point of my question is, am I stuck with the way jQuery 'choreographs' the show() function (without having to modify jQuery itself)? That's what I want to know from people more experienced than I am at jQuery.

When a duration, a plain object, or a "complete" function is provided, .show() becomes an animation method. The .show() method animates the width, height, and opacity of the matched elements simultaneously.

So not only is it built on the animation class, it is predefined to animate the width, height and opacity only and at the same rate. So it other words you can't edit it.

Rob Jurd, you answered my question directly, and that was what I wanted to know, as you said succinctly -- "it is predefined to animate the width, height and opacity only and at the same rate. So it other words you can't edit it."

Thanks for the points and I'm glad you understood how .show() now works. I do feel that I just re-jigged slightly what Gary had already said, and his examples of the .animate() functions do now tie in with what we've said. They also show you how you can essentially modify the .show() function, which was your original question.

If it's ok with you, would a split of the points be ok?

Rob

elepilAuthor Commented: 2014-11-29

Rob, here is a portion of my original post.

"The show() function clearly animates by expanding the width, height, and opacity in a certain way. Is there a way to alter that? For example, what if I wanted only the height to expand and not the width, or vice versa?"

Gary answered with the animate() function, which was not the function I was asking about. When you said, "it is predefined to animate the width, height and opacity only and at the same rate. So it other words you can't edit it.", you said the two key things that I needed to know.

Gary has been pretty good in answering a lot of my past questions, and he has gotten quite a bit of points from me. I like to be generous, but I have to be fair. I give out points not only based on whether or not a responder gave me a correct answer, I also weight them based on how succinct and clear they were. In this case, you satisfied both criteria.

Had Gary just said I can't change it but have to use a different function, he would've gotten points. I go through great pains to make my question brief, simple, and specific, then I cross my fingers and hope responders would read it carefully. You apparently did, and your answer was concise, to-the-point, leaving me with nothing more to ask, that's why you got all the points.

For whatever it's worth, you are clearly a noble man for this request you made.