Skip to main content

jQuery Plugin: REUSABLE CODE (Sumber: Microsoft CoPilot)

🧩 What Is a jQuery Plugin?

A jQuery plugin is a reusable piece of JavaScript code that extends the functionality of the jQuery library. It allows developers to add custom methods to jQuery objects, enabling consistent behavior across multiple elements or projects.


🔍 Core Concept

Responsive image


🧩 jQuery Plugin Example:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>jQuery Plugin Demo: highlight()</title>
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <style>
    body { font-family: Arial, sans-serif; padding: 20px; }
    .highlighted { padding: 10px; margin: 10px 0; border: 1px solid #ccc; }
  </style>
</head>
<body>
  <h2>jQuery Plugin Example: <code>highlight()</code></h2>
  <p class="highlighted">This is paragraph one.</p>
  <p class="highlighted">This is paragraph two.</p>
  <p class="highlighted">This is paragraph three.</p>
  <button id="applyHighlight">Apply Highlight</button>
  <script>
    (function($) {
      $.fn.highlight = function(color) {
        var bgColor = color || 'yellow';
        return this.each(function() {
          $(this).css('background-color', bgColor);
        });
      };
    })(jQuery);
    $(document).ready(function() {
      $('#applyHighlight').on('click', function() {
        $('.highlighted').highlight('#ffeb3b');
      });
    });
  </script>
</body>
</html>

🔍 Breakdown of Key Sections

Responsive image

🧠 Teaching Tip or Workshop Use

You could extend this by:

  • Adding input fields to dynamically change the color
  • Logging plugin behavior to console for debugging
  • Localizing button text for Indonesian audiences (Terapkan Sorotan)

🖥️ What You’ll See When You Run the Example

When you open the .html file in a browser:

  1. Three paragraphs appear with the class highlighted.
  2. A button labeled "Apply Highlight" sits below them.
  3. When you click the button:
    • Each paragraph’s background color changes to a bright yellow (#ffeb3b).
    • The change is instant, thanks to jQuery’s DOM manipulation.
    • You can modify the plugin to accept different colors or add animation effects.

This is a simple but powerful demonstration of how jQuery plugins encapsulate reusable logic and apply it across selected elements.


✅ Benefits of Using jQuery Plugins

  • Reusability: Write once, use across multiple projects or components.
  • Modularity: Keeps code organized and encapsulated.
  • Community: Thousands of open-source plugins available for UI, forms, media, and more.
  • Ease of Use: Simple syntax and integration with existing jQuery code.

🔧 Common jQuery Plugin Categories

  • Form: Validation, input masks, drag-and-drop builders, date/time pickers.
  • UI/UX: Modals, sliders, accordions, tooltips, tabs, carousels.
  • Media: Image galleries, video backgrounds, lightboxes.
  • Performance: Lazy loading, infinite scroll, dynamic content loading.
  • Data: Tables, charts, graphs, filtering, sorting.
  • Accessibility: ARIA enhancements, keyboard navigation, screen reader support.

🌟 Popular & Useful Plugins

  • FullCalendar: Feature-rich event calendar with drag-and-drop support — View Plugin
  • Tagify: Lightweight tags input field with autocomplete — View Plugin
  • Magnific Popup: Responsive lightbox/modal for images, AJAX, and iframes — View Plugin
  • Autosize: Auto-adjust textarea height based on input — View Plugin
  • iCheck: Custom checkboxes/radio buttons with accessibility features — View Plugin
  • BttrLazyLoading: Loads images only when they enter the viewport — View Plugin
  • Face Detection: Detects faces in images, videos, and canvas — View Plugin

📚 Where to Explore More


🎥 Video Demos That Expand the Concept

Here are some excellent video resources that show jQuery plugins in action—each one adds a layer of insight or variation:

  1. jQuery Tutorial - 121 - Highlight search plugin
    This video walks through building a search-based highlight plugin. It’s a great extension of the basic concept, showing how to dynamically highlight matching text based on user input.
  2. Javascript Highlight.js Example to Highlight Source Code in ...
    While not jQuery-based, this shows how highlight.js is used to style code blocks. It’s useful if you’re considering syntax highlighting in educational or documentation contexts.
  3. Highlight Select2 Elements Using jQuery
    Demonstrates how to visually emphasize form elements styled with the Select2 plugin. This is perfect for enhancing user experience in complex forms.
  4. Quick Tip: How to Add Syntax Highlighting to Any Project
    Offers a fast overview of integrating syntax highlighting into any web project. It complements the plugin concept by showing how to modularize visual enhancements.
  5. jQuery image gallery
    A practical example of a jQuery plugin used to build an interactive image gallery. It’s a great next step if you want to explore media-focused plugins.
  6. How to use jQuery MIXIT up Plugin with HTML CSS | HTML ...
    This tutorial shows how to use the MixItUp plugin for filtering and sorting content. It’s ideal for dynamic layouts and portfolio-style interfaces.
  7. Day 13: Building a Text Editor with Quill in Vanilla JavaScript
    While it uses Quill (not jQuery), it’s a great reference for building rich text interfaces. You could integrate jQuery plugins for additional formatting controls.

Comments

Popular posts from this blog

RAD PROTOTYPE Web-App: Post-Video & Comments [program]

Video List — JP Kanji Ultra Translation CONTROL SECTION — Login (Admin) Username: Password: Login CONTROL SECTION — Admin Panel Enable Comments Disable Comments Logout Activity Log Show Video COMMENTS DISABLED BY ADMIN Leave a Comment: Additional Comment Show Video COMMENTS DISABLED BY ADMIN Leave a Comment: Additional Comment Show Video COMMENTS DISABLED BY ADMIN Leave a Comment: Additional Comment Show Video COMMENTS DISABLED BY ADMIN Leave a Comment: Additional Comment

Tips mengeprint POSISI AKURAT!! Microsoft Excel

Gan Kadang mo buat header aka title pada cover sulit membuat PAS posisi Berikut tips dr gw: Buat dulu kerangka di spreadsheet kemudian dibongkar setelah selesai melakukan pengukuran PREPARING (setting Margin + tinggi dan lebar CELL) catatan:  SpreadsheetOffice gw menggunakan satuan milimeter (mm) dalam penentuan jarak margin NUMBERING and BORDERING STEP 1 PRINT PREVIEW CALCULATION to determine CENTER POINT! STEP 2 Setelah gw Print dan Cek  Entah lah  Hasil ukur gw dgn PENGGARIS (biasa)  Menunjukkan bahwa settingan 20mm untuk ukuranTABLE di Microsoft Excel dipresentasikan dgn 21mm pada HasilPrint  Ga tau kenapa begitu Yauwes terima saja! Lanjut dgn perhitungan utk menentukan titik tengah yg penting utk pembuatan Title yg benar-benar berposisi: Ingat ya Gan!   di HASIL PRINT ! Mencari patokan utk   di atas permukaan lembaran Kertas (hasil print) !!   CREATE HEADER aka COVER TITLE STEP 3 CLEANSING  STAGE 4 REMOVE BORDER and NUMBER RESULT

REPOST!! (Doh! Internet lagi lemot2 gimana gitu! Butuh Tool utk Monitor Kecepatan Internet (Download Speed)!!) → Gw ganti dgn nperf.com

KOMPARASI by nperf.com 4 OKTOBER 2025 19.00WIB OXYGEN 4 OKTOBER 2025 19.00WIB XL MACET GAN pake Networx !!! Alternatif dgn menggunakan nperf.com ! #  ChatGPT explain : nPerf adalah aplikasi dan layanan web untuk mengukur kualitas koneksi internet (baik Wi-Fi, data seluler, maupun jaringan kabel). 🔍 Fungsi utama nPerf nPerf digunakan untuk: Speed Test → mengukur kecepatan unduh (download), unggah (upload), dan latensi (ping) . Browsing Test → menilai kecepatan membuka situs web umum (misalnya Google, Facebook, YouTube). Streaming Test → menguji performa streaming video (buffering, resolusi, fps). Coverage Map → peta cakupan jaringan (4G, 5G, Wi-Fi) berdasarkan hasil uji pengguna di seluruh dunia. 💻 Cara Menggunakan Via Website Buka https://www.nperf.com → Klik “Start Test” untuk langsung menjalankan pengu...