tab/re
Due by January 03, 2026
40% complete
Download
API Documentation
Blog
Plugins
Browser Support
Navigate...DownloadAPI DocumentationBlogPluginsBrowser Support
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1076265-1']);
_gaq.push(['_setDomainName', 'jquery.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript" src="//jquery.com/wp-includes/js/comment-reply.min.js?ver=4.4"></script>
<script type="text/javascript" src="//jquery.com/wp-includes/js/wp-embed.min.js?ver=4.4"></script>
!--[if IE 6 ]> <![endif]-->
!--[if IE 7]> <![endif]-->
!--[if IE 9 ]> <![endif]-->
!--[if IE 6 ]> <![endif]-->
!--[if IE 7]> <![endif]-->
!--[if IE 9 ]> <![endif]-->
jQuery
<aside><div id="broadcast"></div></aside>
</div>
<nav id="main" class="constrain clearfix">
<div class="menu-top-container">
<ul id="menu-top" class="menu l_tinynav2">
<form method="get" class="searchform" action="//jquery.com/">
<button type="submit" class="icon-search"><span class="visuallyhidden">search</span></button>
<label>
<span class="visuallyhidden">Search jQuery</span>
<input type="text" name="s" value="" placeholder="Search">
</label>
<div id="content-wrapper" class="clearfix row">
<h3>Event Handling</h3>
<p>Show the <code>#banner-message</code> element that is hidden with
<code>display:none</code> in its CSS when any button in <code>#button-container</code> is
clicked.</p>
<div class="syntaxhighlighter javascript">
<table>
<tbody>
<tr>
<td class="gutter">
<div class="line n1">1</div>
<div class="line n2">2</div>
<div class="line n3">3</div>
<div class="line n4">4</div>
</td>
<td class="code">
<pre><div class="container"><div class="line"><code><span class="keyword">var</span> hiddenBox = $( <span class="string">"#banner-message"</span> );</code></div></div><div class="container"><div class="line"><code>$( <span class="string">"#button-container button"</span> ).on( <span class="string">"click"</span>, <span class="keyword">function</span>( event ) {</code></div></div><div class="container"><div class="line"><code> hiddenBox.show();</code></div></div><div class="container"><div class="line"><code>});</code></div></div></pre>
</td>
</tr>
</tbody>
</table>
<h3>Ajax</h3>
<p>Call a local script on the server <code>/api/getWeather</code>
with the query parameter <code>zipcode=97201</code>
and replace the element <code>#weather-temp</code>'s html with the returned text.</p>
<div class="syntaxhighlighter javascript">
<table>
<tbody>
<tr>
<td class="gutter">
<div class="line n1">1</div>
<div class="line n2">2</div>
<div class="line n3">3</div>
<div class="line n4">4</div>
<div class="line n5">5</div>
<div class="line n6">6</div>
<div class="line n7">7</div>
<div class="line n8">8</div>
<div class="line n9">9</div>
</td>
<td class="code">
<pre><div class="container"><div class="line"><code>$.ajax({</code></div></div><div class="container"><div class="line"><code> url: <span class="string">"/api/getWeather"</span>,</code></div></div><div class="container"><div class="line"><code> data: {</code></div></div><div class="container"><div class="line"><code> zipcode: <span class="number">97201</span></code></div></div><div class="container"><div class="line"><code> },</code></div></div><div class="container"><div class="line"><code> success: <span class="keyword">function</span>( data ) {</code></div></div><div class="container"><div class="line"><code> $( <span class="string">"#weather-temp"</span> ).html( <span class="string">"<strong>"</span> + data + <span class="string">"</strong> degrees"</span> );</code></div></div><div class="container"><div class="line"><code> }</code></div></div><div class="container"><div class="line"><code>});</code></div></div></pre>
</td>
</tr>
</tbody>
</table>
</div>
Copyright 2016 The jQuery Foundation. jQuery License Web hosting by Media Temple | CDN by MaxCDN | Powered by WordPress | Thanks: Members, Sponsors
</div>