JQuery Quiz I
1. In jQuery terminology, what is the difference between the “jQuery function” and the “jQuery object”?
Solution:- When the jQuery function is invoked with a CSS selector, it will return a jQuery object wrapping any element(s) that match this selector. Jquery object doen't represnet the DOM object.
2. Write jQuery code to find all h1 elements that are children of a div element and make their background color red. HTML CODE: <body> <h1>abc</h1><br> <div> <h1>div-1</h1> <h1>div-2</h1> </div> <h1>xyz</h1> </body>
Solution:- $(document).ready(() => $("div h1").css("background-color", "red"));
3. Use a jQuery method to insert the text "YES!" at the end of the <p> element. <!DOCTYPE html> <html> <head> <script> <!—INSERT YOUR JQUERY CODE HERE - - > </script> </head> <body> < p>Is jQuery FUN or what? </p> </body> </html>
Solution:- $(document).ready(() => $("p").append("<p> Yes!!</p>"));