jQuery Code Grabber
Copy jQuery CDN script tags and quick-start snippets.
jQuery CDN (code.jquery.com)
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
jQuery CDN (jsDelivr)
<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"></script>
jQuery CDN (cdnjs)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
Document ready
$(function () {
// DOM is ready
}); Click handler
$('#button').on('click', function (event) {
event.preventDefault();
}); AJAX GET request
$.ajax({
url: '/api/data',
method: 'GET',
dataType: 'json'
}).done(function (data) {
console.log(data);
}).fail(function (xhr, status, error) {
console.error(error);
}); Toggle class
$('.element').toggleClass('active'); Fade in / out
$('#box').fadeIn(300);
$('#box').fadeOut(300);