Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// Release $ for other libraries $.noConflict(); // jQuery still works via the jQuery global jQuery('#my-div').text('Hello from jQuery!'); // Store jQuery in a custom alias var jq = jQuery.noConflict(); jq('#my-div').addClass('active'); // Best practice: IIFE to keep $ locally (function ($) { // Inside here $ safely refers to jQuery $('#header').fadeIn(400); $('#nav a').on('click', function (e) { e.preventDefault(); $('#content').load($(this).attr('href')); }); })(jQuery); // Document-ready shorthand with IIFE jQuery(function ($) { // DOM ready, $ is safe here $('p').css('color', 'darkblue'); });
Result
Open