Top Jquery Interview Questions and Answers in Hindi

इस आर्टिकल में common पूछे जाने वाले jquery interview questions and answers hindi में जानेगें | आशा है इससे आपको काफी मदद मिलेगी |

Jquery Interview Questions and answers Hindi

1) jquery क्या है?

Answer : jquery एक open source javascript library है | जिसे कोई भी अपनी programming में इस्तेमाल कर सकता है | इसमे कई built-in functions है जिससे कम code में ज्यादा काम किया जा सकता है | इसीलिए jquery का मुख्य moto है “write less do more” |

2) jquery के क्या मुख्य features हैं?

Answer : jquery के मुख्य features हैं

  1. light-weight : jquery एक light-weight library है जो server से जल्दी download हो जाती है और memory में जल्दी load हो जाती है | इसीलिए इसकी execution बहोत तेज़ी से हो पाती है |
  2. cross-browser support : ये सारे browsers को support करती है |
  3. DOM-Traversing : dom objects को jquery functions के जरिये आसानी से access कर सकतें हैं |
  4. DOM-Manipulation : dom structure में jquery functions के जरिये आसानी से बदलाव किया जा सकता है |
  5. Ajax-Support : ajax fuction implementation आसानी से किया जा सकता है |
  6. Effects in jquery : jquery के जरिये html elements में animations और दुसरे कई तरह के effects दिए जा सकते हैं जिससे वेबपेज और ज्यादा आकर्षित बन पाती है |

3) क्या jquery javascript की replacement है?

Answer : jquery javascript की replacement नहीं है | jquery एक library है जिसे javascript के code के जरिये बनायी गयी है | jquery के जरिये client side program लिखना ज्यादा आसान होता है |

4) jquery में $(dollar sign) का क्या मतलब होता है ?

Answer : $(dollar) jquery का उपनाम (alias) है |

5) jquery code execution की सुरुआत कहाँ से होती है ?
Answer: jquery code execution की सुरुआत $(document).ready() function से होती है और ये DOM load होने के बाद सुरु होती है |

6) क्या एक से ज्यादा document.ready() function एक वेबपेज में रख सकतें हैं?
answer: हाँ एक से ज्यादा document.ready() function एक पेज में लिखी जा सकती है |

7) jquery में $ sign के बदले अपनी खुदकी कोई खास letter इस्तेमाल कर सकतें ?
Answer : हाँ किया जा सकता है और jquery.noconflict() method की मदद से कर सकतें हैं |

उदाहरण : var $n = jquery.noconflict();

8) window.load() और document.ready() में क्या फर्क है?

  • window.load() function तब execute होता है जब सारे DOM elements content के साथ memory में load हो जाती है | पर document.ready() function सिर्फ DOM elements memory में load होते ही execute हो सकती है |
  • document.ready() function को run करने के लिए पूरी content load होने तक का इंतज़ार करने की जरुरत नहीं पड़ती | पर window.load() funtion को run करने के लिए पूरी content load होने का इंतज़ार करनी पड़ती है |
  • एक वेबपेज में सिर्फ एक window.ready() function लिखी जा सकती है पर document.ready() function एक से अधिक लिखी जा सकती है |

9) CDN क्या है ?

Answer : CDN की fullform है Content Delivery Network | इसे Content Distribution Network भी कही जाती है | ये एक तरीका है जहां एक वेबसाइट में jQuery को वास्तव में डाउनलोड किए बिना और वेबसाइट के फ़ोल्डर में रखे बिना शामिल किया जा सकता है | ऐसे कई 3rd party websites हैं जैसे की Google, Microsoft, CloudFlare आदि जिसे हम अपने वेबसाइट में refer कर सकतें हैं jquery file इस्तेमाल के लीए |

आम तौर पर हम सभी सबसे पहले jQuery फाइल को वेबसाइट के फोल्डर में डाउनलोड करते हैं और उसमे रखतें हैं| फिर हम इस फाइल को पेज के head section पर refer करते हैं।
इसके बजाय हम Google, Microsoft, CloudFlare, आदि से सीधे jQuery का लिंक प्रदान करके jQuery CDN का उपयोग कर सकते हैं।

इससे वेबसाइट की performance speed बढ़ेगी और server पे load भी नहीं पड़ता है |

10) $(this) और this में क्या फर्क है ?

Answer : $(this) एक jquery selector है जो jquery function में current item को refer करता है |

पर this एक javascript keyword है जो javascript की current object को refer करता है |

11) jQuery में chaining क्या है?
Answer: Chaining एक jQuery का feature है | Chaining के जरिये एक से अधिक functions या selectors को एक element में इस्तेमाल किया जा सकता है |

इससे code segment कम होती है और jquery code ज्यादा clean लगती है और समझ में अच्छे से आती है | इससे jquery compilation की speed भी बढती है |

उदाहरण : $(“#div1”).css(“color: blue”).addclass().fadeIn();

12) jquery में कितने तरह के selectors होतें हैं?

  • tag-based selector —– ये selector सारे एक जैसे html tags को select करता है जैसे की <p> tag , <div> tag |
  • id-based selector —- ये selector html element को उसके id के basis पे select करता है |
  • class name —– एक जैसी class name जिन tags को दी गयी होती है उन्हें class selector select करता है |
  • universal selectors(*) —– universal selector जिसे *(asterik) सिंबल से दरसाया जाता है वो सारे elements को select करता है |
  • multiple elements selectors —- एक से अधिक अलग html elements को लेकर इस्तेमाल करने के लिए इसे लिया जाता है |उदाहरण $(“h1, p) |
  • document selector $(document)
  • current item selector $(this) —- current item पे इस्तेमाल करने के लिए $(this) selector को लिया जाता है |

13) jquery के मदद से html elements को style कैसे दे सकतें हैं ?

Answer : jquery में html elements को style देने के लिए इन 5 तरीको का इस्तेमाल होता है |

  1. single property —- css() method के जरिये html element को style दी जाती है | उदाहरण : $(“#p1”).css(“color”, “red”);
  2. multiple properties —- css() method के जरिये html element को style दी जाती है और इसमें एक से ज्यादा css properties को object के जरिये बताई जाती है| उदाहरण : $(“#p1”).css( { “color” : “red”, “background-color” : “yellow” } );
  3. addClass() : इस method से selected element में css class लगायी जाती है | उदाहरण : $(“div1”).addClass(“class1”);
  4. removeClass() : इस method से selected element से css class हटाई जाती है | उदाहरण : $(“div1”).removeClass(“class1”);
  5. toggleClass() : ये method दो तरह से काम करता है | पेहली अगर css class नहीं लगी है तो css class लगाता है और दूसरी css class किसी element लगी है तो उसे हटाता है | उदाहरण : $(“div1”).toggleClass(“class1”);

14) jquery effects क्या है और कितने तरह के होतें हैं ?

Answer: jquery effects से html elements में कुछ special effects लगाने के लिए इस्तेमाल होता है | jquery effects type हैं :

  1. show()
  2. hide()
  3. toggle()
  4. fadeIn()
  5. fadeOut()
  6. fadeToggle()
  7. slideUp()
  8. slideDown()
  9. slideToggle()
  10. animate()

jquery के सारे effects में time duration दी जाती है और duration को milliseconds में दी जाती है | उदाहरण– $(“image1”).fadeIn(2000);

15) jquery में ajax function का इस्तेमाल कैसे होता है ?

Answer : ajax जिसका पूरा नाम है Asynchronous JavaScript and XML और इस technology की मदद से browser को refresh किये बिना server से data को load करा सकतें हैं |

jquery में ajax technology को ajax() method के जरिये implement किया जाता है |

16) jquery में each() function क्या है?

Answer: jquery में each() एक loop की तरह काम करता है | इसे collection या array के elements को access करने के लिए लिया जाता है |

each() function index basis पे run होता है |

Syntax: $(selector).each(function(index, element)) 

Example

<script>
  $(document).ready(function()
   { 
     $("#button1").click(function()
      {
        $("p").each(function()
         {
           var str = $(this).text();
           alert(str);
         }
      });
   });
</script>

17. jquery method के जरिए html element में css class add और remove कैसे करें ?

Answer: jquery addClass() method के जरिये html में css class लगा सकतें हैं | jquery removeClass() method के जरिये किस भी html element से css class हटा सकतें हैं |

Syntax:
$(selector).addClass(“classname);
$(selector).removeClass(“classname);

उदाहरण:
$(“#h1”).addClass(“c1”);
$(“#h1”).removeClass(“”c1”);

18. jQuery में DOM Traversing क्या है?

Answer: DOM Traversing jQuery का prominent feature है | इसके जरिए DOM tree में किसी भी element को select या target किया जा सकता है |

चाहे element parent node में हो या child node में या grant-child node में, DOM tree में up से लेकर down तक किसी भी position के element को DOM traversing methods के जरिए select किया जा सकता है |

DOM traversing methods को 4 मुख्य भागों में बाटां गया है और वो सब अन्य कई methods के समारोह हैं :

  • Ancestors – इसमें methods हैं: 1) parent(), 2) parents(), 3) parentsUntil(), 4) offsetParent(), 5) closest()
  • Descendants – इसमें methods हैं: 1) children(), 2) find()
  • Siblings – इसमें methods हैं: 1) siblings(), 2) next(), 3) nextAll(), 4) nextUntill(), 5) prev(), 6) prevAll(), 7) prevUntill()
  • Filtering – इसमें methods हैं: 1) first(), 2) last(), 3) eq(), 4) filter(), 5) has(), 6) is(), 7) map(), 8) slice()

19. find() vs children() method में क्या अंतर है?

Answer: find() and children methods, jQuery में DOM traversing का descendants method है |

children() method के जरिए किसी element का सिर्फ children elements निकालने के लिए उपयोग में आता है |

find() method के जरिए कोई भी descendant element को find की जा सकती है पर इसके लिए selector में filter condition लगानि पड़ती है |

उदाहरण:

$("div").children().css({"color": "blue"});

$("div").find("span").css({"color": "red",});

20. parent() vs closest() में क्या अंतर है?

Answer: parent() method किसी element का immediate parent को target करता है | वो DOM tree में एक level up से start करता है |

closest() method किसी element का immediate parent को target करता है, पर वो DOM tree में current element यानि खुद से start करता है |

अन्य सुझाव

  1. html interview questions and answers in hindi
  2. CSS interview questions and answers in hindi
  3. Javascript interview questions and answers in hindi