← Back to jQuery Course | Chapter 13: jQuery UI | Lesson 1 of 5

jQuery UI का Introduction

jQuery UI ready-made interface components का एक collection है। यह jQuery के साथ काम करता है और आपको interactive pages बनाने में मदद करता है।
Syntax
javascript
<link rel="stylesheet" href="jquery-ui.css">
<script src="jquery-ui.js"></script>

$("selector").widgetName(options);

jQuery UI क्या है?

jQuery UI jQuery को datepickers, dialogs, sliders, और tabs जैसे pre-built, themeable interface widgets की एक library से extend करता है, आपको इन्हें बनाने से बचाते हुए।

उदाहरण: What is jQuery UI?

javascript
<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
  </head>
  <body>
    <div id="date">Pick a date</div>
    <script>
      $("#date").datepicker();
    </script>
  </body>
</html>

jQuery UI CSS

jQuery UI एक theme stylesheet के साथ आता है जो हर widget के लिए default visual styling देता है — buttons, borders, spacing, और hover जैसी states।

उदाहरण: jQuery UI CSS

javascript
<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
  </head>
  <body>
    <button id="btn">Styled Button</button>
    <script>
      $("#btn").button();
    </script>
  </body>
</html>

पहला Interactive Widget

jQuery UI widgets एक jQuery selection पर किसी widget का initialization method call करके plain HTML elements को richer interactive controls में बदल देते हैं।

उदाहरण: First Interactive Widget

javascript
<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
  </head>
  <body>
    <input id="date">
    <script>
      $("#date").datepicker();
    </script>
  </body>
</html>

Themes और Appearance

एक jQuery UI theme colors, borders, spacing, और overall appearance control करता है जो हर widget इस्तेमाल करता है, और themes को पूरी तरह look बदलने के लिए swap किया जा सकता है।

उदाहरण: Themes and Appearance

javascript
<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
  </head>
  <body>
    <button id="btn">Themed Button</button>
    <script>
      // Swapping the linked jquery-ui.css theme file changes this button's look with no JS changes
      $("#btn").button();
    </script>
  </body>
</html>

एक छोटा Introduction Project

एक ही page पर कई jQuery UI components combine किए जा सकते हैं — उदाहरण के लिए, एक dialog के अंदर एक datepicker, या एक sortable list के अंदर draggable items।

उदाहरण: Small Introduction Project

javascript
<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
  </head>
  <body>
    <div id="dialog" title="Basic dialog">Dialog content</div>
    <script>
      $("#dialog").dialog();
    </script>
  </body>
</html>
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. jQuery UI script load करना लेकिन उसका CSS theme नहीं, ताकि dialogs और datepickers जैसे widgets unstyled या टूटे हुए दिखें।
  2. jQuery UI को जQuery से पहले load करना, ताकि $.fn missing हो जाए और $("#box").draggable() जैसी calls error throw करें।
  3. jQuery UI को core jQuery से confuse करना और सिर्फ jQuery script load होने पर .datepicker() के exist करने की उम्मीद करना।
🔒

Chapter Quiz — Complete all 5 topics to unlock

0/5 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.