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

[ERROR BUG]
ChatGPT+Gemini: TikTok → Blogger Embed Converter using Cloudflare/Online Server

🔄 Refresh Page ERROR BUG: The connection is blocked because it was initiated by a public page to connect to devices or servers on your local network. Planning: Revise Program CODE Code USING Javascript/Online Server Code NOT USING Javascript Sample Working Code aka Already Repaired! Temporary Solution is by Asking AI Assistant to do REPAIR CODE of (Not yet Repaired) Current Conversion Program Code-Output TikTok Archive – Embedded Preview TikTok Embed ▶ View this video on TikTok ⚠️ DISCLAIMER: INPUT URL LIMITATION This program is currently restricted to processing Full Browser URLs only. It does not support TikTok’s mobile "short-link" format (e.g., vt.tiktok.com ). Required Action: Users must open the video in a web browser and copy the expanded URL from the address bar before pasting it into this program. URL Conversion Example ❌ UNSUPPORTED: https://vt.tiktok.com/ZSaXoFyov/ ✅ REQ...

Repost! Web-Based to Android Apps Convertion (MEDIAN.CO etc.)

CONTOH HASIL Android APK "PROGRAM" SAMPLE: Youtube and Instagram EMBEDded to Blogger/Blogspot.com SOURCE CODE Click this box to download Contoh Sample SHORTCUT-APPs "precise" click to download : median.co R8: ronin1985.blogspot.com R2M: ronin-manu.blogspot.com Gw udah coba Median.co utk mengubah Website gw menjadi Aplikasi Android Keren bet!! Median.co Cekidot Software lain yg mirip! ChatGPT : If you're looking for tools similar to Median.co to convert websites into Android apps, here are some top alternatives, especially for no-code or low-code users: 🔧 Best Tools Like Median.co to Convert Website to Android Apps 1. WebViewGold Platform: Windows/macOS (Xcode/Android Studio) Key Feature: Converts any website into iOS/Android app via WebView. Pros: One-time purchase Custom splash screen, push notifications Can open external links in external browser Cons:  Requi...

REPOST: Studying WATER PUMP by ROMAN ENGINEERING

*^ Ini yg Asli Gan! Mekanisme pada Concrete Pump: Kok ky Sistem Mekanik Romawi ya?! Tapi malah bisa HANYA pake PER aka bukan "MATA BOR look a like" Mekanisme Drill yg Cost Pembuatan bikin REPOT aka harus Tool SUPER Khusus Dari Material Besi yg digunakan terlihat langsung secara kasat mata Jauh Lebih Banyak drpd Per Biasa seperti yg ditunjukkan pd Video Alternatif dgn Penggunaan PER Video dr Instagram: Source: YouTube Rome's drainage machines #history #romanempire #engineering