24 Mar Top jQuery Interview Questions and Answers (MCQs)
The jQuery Interview Questions and Answers are given here. The level of questions is suitable for beginners as well as advanced jQuery programmers. These are jQuery Multiple Choice Questions (MCQs).
Q1. jQuery is a?
- Java Library
- JavaScript Library
- Tool
- None of these
Q2. Whatever you achieve with JavaScript can be achieved with jQuery. True / False
- True
- False
Q3. What is the difference between the production and the development version of jQuery?
- Production version is for testing.
- Production version is uncompressed version.
- Development version is used on live website.
- Development version is for testing.
Q4. Should I use <script> or <script type=”text/javascript”>for referencing jQuery in a web document?
- Writing <script type=”text/javascript”> is mandatory
- Since, JavaScript is the scripting language for HTML5, now you can use <script> only to reference jQuery.
- None of the above is required to reference jQuery in a web document.
Q5. To host jQuery, which two jQuery CDNs are available for users?
- Amazon and Akamai
- Cloudflare and Google
- Google and Microsoft
- None of the above
Q6. Which of the following ways when used loads jQuery faster on the web page?
- Hosted jQuery – CDN
- Download and Host – Production Version
- Download and Host – Development Version
- None of the above
Q7. What is the role of a selector in jQuery syntax:
- To access jQuery
- Act to perform operations
- Find matching elements
Q8. Which is the correct jQuery syntax?
- $(document) { }
- $(document).ready(function() { }
- $(jQuery.ready) {}
- $()
Q9. Selectors in jQuery begin with?
- $()
- $
- .jQuery()
- jQuery($)
Q10. Which is the correct form of using Element Selector in jQuery? Let’s say the element is <div>:
- $(“div”)
- $(“#div”)
- $(“.div”)
- None of the above is correct
Q11. Which is the correct form of using Class Selectors in jQuery? Let’s say class = demo
- $(“demo”)
- $(“#demo”)
- $(“.demo”)
- $(demo)
Q12. Which is the correct form of using Id Selector in jQuery? Let’s say id = demo
- $(“demo”)
- $(“.demo”)
- $(demo)
- $(“#demo”)
Q13. How to select all the elements i.e. the right way of using Universal Selector?
- $(“^”)
- $(“*”)
- $(“”)
- $(“$”)
Q14. What is the correct way of selecting the current element with jQuery Selectors?
- $(this)
- $()
- $(“”)
- $(this())
Q15. How can I select all <p> elements with class=”demo” using jQuery Selectors?
- $(“*”)
- $(“.demo”)
- $(“demo”)
- $(“p.demo”)
Q16. A lot of <p> elements are present in the HTML document. How to select the first <p> element using jQuery Selectors?
- $(“p “)
- $(“p:first”)
- $(“p^”)
- None of the above
Q17. How to select the first <li> element of the first unordered list element i.e. <ol> using jQuery Selectors?
- $(“ol first”)
- $(“ol first, li:first”)
- $(“ol li:first”)
- $(“ol: li:first”)
Q18. Using jQuery Selectors how to select all even <tr> elements in an HTML table:
- $(“tr:even”)
- $(“tr: 2”)
- $(“tr>even”)
- None of the above
Q19. Using jQuery Selectors, how to select all elements with the attribute href:
- $(“*href”)
- $(“*”)
- $(“href”)
- $(“[href]”)
Q20. Using jQuery Selectors how to select all even <td> elements in an HTML table.
- $(“td: 2”)
- $(“td:even”)
- $(“td>even”)
- None of the above
Q21. How to select all elements that are children of a <p> element with jQuery Selectors?
- $(“p > *”)
- $(“*”)
- $(“p <*”)
- $(“p :child”)
Q22. Using jQuery Selectors, how to select all elements matched by <li>, which do not have class = “demo”.
- $(“li:not.demo”)
- $(“li:not(#demo)”)
- $(“li:not(demo)”)
- $(“li:not(.demo)”)
Q23. How can we select all elements matched by <a> with href attribute value containing studyopedia.com.
- $(“a[href*=studyopedia.com]”)
- $(“a[@href=studyopedia.com]”)
- $(“a[@href*=studyopedia.com]”)
- None of the above
Q24. With jQuery Selectors, how to select all elements matched by <li> that are visible?
- $(“li:visible”)
- $(“visible”)
- $(“*visible”)
- $(“li*:visible”)
Q25. How to select all radio buttons using jQuery Selectors?
- $(“radio”)
- $(“*radio”)
- $(“:radio”)
- None of the above
Q26. With jQuery Selectors, how to select all elements matched by <li> that are hidden?
- $(“hidden”)
- $(“*hidden”)
- $(“li*:hidden”)
- $(“li:hidden”)
Q27. In a form, how to select all checked boxes using jQuery Selector.
- $(“:checked”)
- $(“checked”)
- $(“*checked”)
- $(“* “)
Q28. In a web page, form elements like input, textarea, button, etc are added with other elements. How to select only the form elements using jQuery?
- $(“input”)
- $(“^input”)
- $(“:input”)
- None of the above
Q29. From a list of <li> elements in <ul>, how to select the 4th element?
- $(“li:eq(3)”)
- $(“li:eq(4)”)
- $(“eq(4)”)
- None of the above
Q30. From a list of <li> elements in <ul>, how to select the first five elements?
- $(“li:eq(5)”)
- $(“li:eq(4)”)
- $(“li:lt(5)”)
- $(“li:lt(4)”)
Q31. With jQuery Selectors, how to select all elements matched by <li>, which contain the text demo.
- $(“li:contains(demo)”)
- $(“contains(demo)”)
- $(“li (demo)”)
- None of the above
Q32. With jQuery Selectors, select all elements matched by <li>, which are the first child of their parent.
- $(“first-child”)
- $(“li:first”)
- $(“li:first-child”)
- None of the above
Q33. Select elements matched by <p> element that are children of an element matched by <div> element, using jQuery Selectors.
- $(“div p”)
- $(“div(p)”)
- $(“div:p”)
- $(“div/p”)
Q34. With jQuery Selectors, select all elements matched by <li>, which are the last child of their parent.
- $(“li:last-child”)
- $(“last-child”)
- $(“li:last”)
- None of the above
Q35. With jQuery Selectors how to select elements, that are the parent of another element?
- $(“parent”)
- $(“:parent”)
- $(parent)
- None of the above
Q36. How to get the value of an attribute for the first element in the set of matched elements.
- getAttr()
- attr()
- getAttributes()
- None of the above
Q37. Which of the following jQuery methods are used to remove an attribute?
- removeAttr()
- attr()
- empty()
- None of the above
Q38. Which of the following methods is used to get the text content of the matched element?
- HTML()
- text()
- Both of the above
- None of the above
Q39. How to set the alt attribute of all the images. Add the value Technology to the alt tag:
- $attr(“alt”, “Sample Image”)
- $(“*”).attr(“alt”, “Sample Image”)
- $(“img”).attr(“alt”, “Technology”)
- None of the above
Q40. Set the title of all <input> elements to “Enter Value”
- $(“input”).attr({ title: “Enter Value” });
- $(“*”).attr({ title: “Enter Value” });
- $(“input”).(title: “Enter Value”);
- None of the above
Q41. Which of the following methods is used to get the HTML content of the matched element?
- HTML()
- text()
- Both of the above
- None of the above
Q42. With jQuery, how to remove the target attribute of all the links on the web page:
- $(“a”).empty(“target”)
- $(“a”).remove(“target”)
- $(“a”).removeAttr(“target”)
- None of the above
Q43. How can we get the text content of all matched <p> elements?
- $(“p”).text()
- $(p:text())
- $(“*”).text()
- None of the above
Q44. In a checked checkbox, how to get the first value?
- $(“checkbox:checked”).val()
- $(“input:checkbox:checked”).val()
- $(“input:checkbox”).val()
- None of the above
Q45. A dropdown has the following values: Ronaldo, Messi, Neymar. From here, how to select the option, “Messi”?
- $(“select”).val(“Messi”)
- $(“*”).val(“Messi”)
- $(“select.val(“Messi”))
- $(“select: Messi”)
Q46. How to get the HTML content of all matched <p> elements:
- $(p:HTML())
- $(“*”).html()
- $(“p”).html()
- None of the above
Q47. A dropdown is having the following values: Ronaldo, Messi, Neymar, and Ronaldinho. From here, how to select the options Neymar, Messi, Ronaldinho?
- $(“*”).val(“Neymar”,”Messi”, “Ronaldinho”)
- $(“select”).val(“Neymar”,”Messi”, “Ronaldinho”)
- $(“select.val(“Neymar”,”Messi”, “Ronaldinho”))
- None of the above
Q48. How to select all elements with class “demo” or “test”
- $(“.demo,.test”)
- $(“.demo:.test”)
- $(“demo,test”)
- $(“demo+ test”)
Q49. How to select multiple elements in jQuery. The total elements are <h1>, <h2>, <div>,<span>, <p>. Select only the following: <h1>,<h2>,<div>
- $(“*”)
- $(“h1:h2:div”)
- $(“h1:div:div”).val()
- $(“h1,h2,div”)
Q50. How to select the nth child in jQuery. Select all <p> elements which are the 3rd child of their parent:
- $(“p:nth-child(3)”)
- $(“p-child(3)”)
- $(“p.child(2)”)
- None of the above
Q51. How to get all <p> elements, which are the only child of their parent:
- $(“p^only-child”)
- $(“p:child”)
- $(“p:only-child”)
- None of the above
Q52. How to get all the <p> elements, which are direct child of <div>:
- $(“div > p”)
- $(“div.p”)
- $(“*p”)
- $(“div > *p”)
Q53. With jQuery, get all <p> elements that are siblings of a <div>:
- $(“div ~ p”)
- $(“div: p”)
- $(div < p)
- None of these
Q54. Get all <input> elements that are not empty.
- $(“input>not(:empty)”)
- $(“input*not(:empty)”)
- $(“input:not(:empty)”)
- None of these
Q55. With jQuery, how to get <p> elements that are descendants of a <div>.
- $(“div.p”)
- $(div p)
- $(“*p”)
- $(“div > *p”)
Q56. How to get all animated elements in jQuery?
- $(“animated”)
- $(“*animated”)
- $(“*”)$(“:animated”)
Q57. The web page has headers like <h1>, <h2>, <h3>. How to get them in jQuery?
- $(“*header”)
- $(“:header”)
- $(“header”)
- None of these
Q58. Select all <div> elements that have a <ul> element.
- $(“div:has(ul)”)
- $(“*div:has(ul)”)
- $(“div > ul”)
- $(“div ~ ul”)
Q59. How can we select all hidden <ul> elements in jQuery?
- $(“ul>hidden”)
- $(“ul:hidden”)
- $(“ul~hidden”)
- None of these
Q60. How to select all input elements with type=”text”.
- $(“text”)
- $(“:text”)
- $(“*text”)$(“^text”)
Q61. In jQuery, how to get all the elements with the “href” attribute.
- $(“[href]”)
- $(“(href)”)$(“*href”)
- None of these
Q62. With jQuery, how to select all elements with “href” attribute value “studyopedia.com”
- $(“[href=’studyopedia.com’]”)
- $(“(href=’studyopedia.com’)]”)
- $(“(href: ‘studyopedia.com’)”)
- None of these
Q63. Select all <p> elements with a lang attribute value starting with “test”.
- $(“p>lang(test)”)
- $(“p.lang(test)”)
- $(“p:lang(test)”)
- None of these
Q64. With jQuery, how to select all elements with “href” attribute value not equal to “studyopedia.com”
- $(“[!href=’studyopedia.com’]”)
- $(“(href!=’studyopedia.com’)]”)
- $(“not(href: ‘studyopedia.com’)”)
- None of these
Q65. How to select all input elements with type=”password”.
- $(“type=password”)
- $(“password “)
- $(“*password”)
- $(“:password”)
Q66. Select all elements with a “href” attribute value, which ends with “.png”.
- $(“[href=’.png’]”)
- $(“[href>.png]”)
- $(“[href$=’.png’]”)
- None of these
Q67. Select all elements with a “title” attribute value beginning with “Study”.
- $(“[title^=Study]”)
- $(“[title=Study]”)
- $(“[title*=Study]”)
- None of these
Q68- Select all elements with a “title” attribute value containing the word “Demo” specifically.
- $(“[title=Study]”)
- $(“[title^=Study]”)
- $(“[title~=Demo]”)
- None of these
Q69. How to select all disabled input elements.
- $(“:disabled”)
- $(“disabled”)
- $(“*disabled”)
- None of these
Q70. With jQuery, how to select all buttons and input elements of type=”button”.
- $(“~button”)
- $(“button”)
- $(“:button”)
- None of above
If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.
For Videos, Join Our YouTube Channel: Join Now
Read More:
No Comments