1 line
9.6 KiB
JSON
1 line
9.6 KiB
JSON
{"name":"show","type":"method","title":".show()","deprecated":null,"removed":null,"desc":"Display the matched elements.","categories":["effects/basics","version/1.0","version/1.4.3"],"entries":[{"return":"jQuery","signatures":[{"added":"1.0"},{"added":"1.0","argument":[{"desc":"A string or number determining how long the animation will run.","type":[{"name":"Number"},{"name":"String"}],"name":"duration","default":"400","optional":"true"},{"desc":"A function to call once the animation is complete.","name":"complete","type":"Function","optional":"true"}]},{"added":"1.0","argument":{"desc":"A map of additional options to pass to the method.","property":[{"desc":"A string or number determining how long the animation will run.","type":[{"name":"Number"},{"name":"String"}],"name":"duration","default":"400"},{"desc":"A string indicating which easing function to use for the transition.","name":"easing","type":"String","default":"swing"},{"desc":"A Boolean indicating whether to place the animation in the effects queue. If false, the animation will begin immediately. <strong>As of jQuery 1.7</strong>, the queue option can also accept a string, in which case the animation is added to the queue represented by that string. When a custom queue name is used the animation does not automatically start; you must call <code>.dequeue(\"queuename\")</code> to start it.","type":[{"name":"Boolean"},{"name":"String"}],"name":"queue","default":"true"},{"desc":"A map of one or more of the CSS properties defined by the properties argument and their corresponding easing functions.","name":"specialEasing","type":"PlainObject","added":"1.4"},{"desc":"A function to be called for each animated property of each animated element. This function provides an opportunity to modify the Tween object to change the value of the property before it is set.","argument":[{"desc":"The numeric value of the property being animated at each step","name":"now","type":"Number"},{"desc":"An object of properties related to the animation and the element being animated. For information about the tween object and its properties, see <ahref=\"/jQuery.Tween/\">jQuery.Tween</a>","name":"tween","type":"Tween"}],"name":"step","type":"Function"},{"desc":"A function to be called after each step of the animation, only once per animated element regardless of the number of animated properties.","argument":[{"desc":"An enhanced Promise object with additional properties for the animation","name":"animation","type":"Promise"},{"desc":"A number from 0 to 1 indicating the progress of the animation","name":"progress","type":"Number"},{"desc":"A number indicating the remaining number of milliseconds until the scheduled end of the animation","name":"remainingMs","type":"Number"}],"name":"progress","type":"Function","added":"1.8"},{"desc":"A function to call once the animation is complete.","name":"complete","type":"Function"},{"desc":"A function to call when the animation begins.","argument":{"desc":"An enhanced Promise object with additional properties for the animation","name":"animation","type":"Promise"},"name":"start","type":"Function","added":"1.8"},{"desc":"A function to be called when the animation completes (its Promise object is resolved).","argument":[{"desc":"An enhanced Promise object with additional properties for the animation","name":"animation","type":"Promise"},{"desc":"Indicates whether the animation jumped to the end","name":"jumpedToEnd","type":"Boolean"}],"name":"done","type":"Function","added":"1.8"},{"desc":"A function to be called when the animation fails to complete (its Promise object is rejected).","argument":[{"desc":"An enhanced Promise object with additional properties for the animation","name":"animation","type":"Promise"},{"desc":"Indicates whether the animation jumped to the end","name":"jumpedToEnd","type":"Boolean"}],"name":"fail","type":"Function","added":"1.8"},{"desc":"A function to be called when the animation completes or stops without completing (its Promise object is either resolved or rejected).","argument":[{"desc":"An enhanced Promise object with additional properties for the animation","name":"animation","type":"Promise"},{"desc":"Indicates whether the animation jumped to the end","name":"jumpedToEnd","type":"Boolean"}],"name":"always","type":"Function","added":"1.8"}],"name":"options","type":"PlainObject"}},{"added":"1.4.3","argument":[{"desc":"A string or number determining how long the animation will run.","type":[{"name":"Number"},{"name":"String"}],"name":"duration","default":"400"},{"desc":"A string indicating which easing function to use for the transition.","name":"easing","type":"String","default":"swing","optional":"true"},{"desc":"A function to call once the animation is complete.","name":"complete","type":"Function","optional":"true"}]}],"examples":[{"desc":"Animates all hidden paragraphs to show slowly, completing the animation within 600 milliseconds.","code":"\n$( \"button\" ).click(function() {\n $( \"p\" ).show( \"slow\" );\n});\n","css":"\n p {\n background: yellow;\n }\n","html":"\n<button>Show it</button>\n<p style=\"display: none\">Hello 2</p>\n"},{"desc":"Show the first div, followed by each next adjacent sibling div in order, with a 200ms animation. Each animation starts when the previous sibling div's animation ends.","code":"\n$( \"#showr\" ).click(function() {\n $( \"div\" ).first().show( \"fast\", function showNext() {\n $( this ).next( \"div\" ).show( \"fast\", showNext );\n });\n});\n\n$( \"#hidr\" ).click(function() {\n $( \"div\" ).hide( 1000 );\n});\n","css":"\n div {\n background: #def3ca;\n margin: 3px;\n width: 80px;\n display: none;\n float: left;\n text-align: center;\n }\n","html":"\n<button id=\"showr\">Show</button>\n<button id=\"hidr\">Hide</button>\n<div>Hello 3,</div>\n<div>how</div>\n<div>are</div>\n<div>you?</div>\n"},{"desc":"Show all span and input elements with an animation. Change the text once the animation is done.","code":"\nfunction doIt() {\n $( \"span,div\" ).show( \"slow\" );\n}\n// Can pass in function name\n$( \"button\" ).click( doIt );\n\n$( \"form\" ).submit(function( event ) {\n if ( $( \"input\" ).val() === \"yes\" ) {\n $( \"p\" ).show( 4000, function() {\n $( this ).text( \"Ok, DONE! (now showing)\" );\n });\n }\n $( \"span,div\" ).hide( \"fast\" );\n\n // Prevent form submission\n event.preventDefault();\n});\n","css":"\n span {\n display: none;\n }\n div {\n display: none;\n }\n p {\n font-weight: bold;\n background-color: #fcd;\n }\n","html":"\n<button>Do it!</button>\n<span>Are you sure? (type 'yes' if you are) </span>\n<div>\n <form>\n <input type=\"text\" value=\"as;ldkfjalsdf\">\n </form>\n</div>\n<p style=\"display:none;\">I'm hidden...</p>\n"}],"longdesc":"\n <p>With no parameters, the <code>.show()</code> method is the simplest way to display an element:\n </p>\n <pre><code>\n$( \".target\" ).show();\n </code></pre>\n <p>The matched elements will be revealed immediately, with no animation. This is roughly equivalent to calling <code>.css( \"display\", \"block\")</code>, except that the <code>display</code> property is restored to whatever it was initially. If an element has a <code>display</code> value of <code>inline</code>, then is hidden and shown, it will once again be displayed <code>inline</code>.</p>\n <p><strong>Note: </strong> If using !important in your styles, such as\n <code>display: none !important</code>,\n it is necessary to override the style using <code>.css( \"display\", \"block !important\")</code> should you wish for <code>.show()</code> to function correctly.</p>\n <p>When a duration, a plain object, or a \"complete\" function is provided, <code>.show()</code> becomes an animation method. The <code>.show()</code> method animates the width, height, and opacity of the matched elements simultaneously.</p>\n <p>Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The strings <code>'fast'</code> and <code>'slow'</code> can be supplied to indicate durations of <code>200</code> and <code>600</code> milliseconds, respectively.</p>\n <p>As of jQuery 1.4.3, an optional string naming an easing function may be used. Easing functions specify the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, called <code>swing</code>, and one that progresses at a constant pace, called <code>linear</code>. More easing functions are available with the use of plug-ins, most notably the <a href=\"http://jqueryui.com\">jQuery UI suite</a>.</p>\n <p>If supplied, the callback is fired once the animation is complete. This can be useful for stringing different animations together in sequence. The callback is not sent any arguments, but <code>this</code> is set to the DOM element being animated. If multiple elements are animated, it is important to note that the callback is executed once per matched element, not once for the animation as a whole.</p>\n <p>We can animate any element, such as a simple image:</p>\n <pre><code>\n<div id=\"clickme\">\n Click here\n</div>\n<img id=\"book\" src=\"book.png\" alt=\"\" width=\"100\" height=\"123\">\nWith the element initially hidden, we can show it slowly:\n$( \"#clickme\" ).click(function() {\n $( \"#book\" ).show( \"slow\", function() {\n // Animation complete.\n });\n});\n </code></pre>\n <p class=\"image four-across\">\n <img src=\"/resources/0042_06_01.png\" alt=\"\"/>\n <img src=\"/resources/0042_06_02.png\" alt=\"\"/>\n <img src=\"/resources/0042_06_03.png\" alt=\"\"/>\n <img src=\"/resources/0042_06_04.png\" alt=\"\"/>\n </p>\n "}]} |