What is the basic syntax of jQuery?
A
$(selector).action() B
query(selector).action() C
$[selector].action() D
jQuery:selector.action()
Analysis & Theory
The basic syntax of jQuery is `$(selector).action()`, where `$` is the jQuery symbol.
What does the `$` symbol represent in jQuery?
A
CSS B
HTML C
jQuery function D
Java function
Analysis & Theory
The `$` is a shorthand for the jQuery function.
Which of the following is the correct syntax to select all `<p>` elements?
A
$('p') B
$('#p') C
$('.p') D
$(p)
Analysis & Theory
`$('p')` selects all `<p>` tags in the document.
Which is the correct jQuery syntax to hide an element with id 'test'?
A
$('test').hide() B
$('.test').hide() C
$('#test').hide() D
hide('#test')
Analysis & Theory
`$('#test').hide()` hides the element with id 'test'.
How do you select an element with class 'example' in jQuery?
A
$('.example') B
$('#example') C
$('example') D
$('*.example')
Analysis & Theory
`$('.example')` selects all elements with the class name 'example'.
What is the purpose of `$(document).ready(function(){ ... });`?
A
Runs code when the document is loading B
Runs code after the page loads C
Runs code when the document is ready D
Runs code after clicking a button
Analysis & Theory
`$(document).ready()` ensures the jQuery code runs after the DOM is fully loaded.
Which of the following is correct for changing the text of an element with id 'demo'?
A
$('#demo').value('Hello') B
$('#demo').text('Hello') C
$('demo').setText('Hello') D
$('#demo').html('Hello')
Analysis & Theory
`$('#demo').text('Hello')` sets the text content of the element with id 'demo'.
How do you change the CSS background color of all `<h1>` elements to red?
A
$('h1').css('background-color','red') B
$('h1').style('background','red') C
$('h1').setCSS('background','red') D
$('h1').setStyle('background-color','red')
Analysis & Theory
`$('h1').css('background-color','red')` changes the CSS background color of all `<h1>` elements to red.
Which is the correct syntax to fade out an element with id 'box'?
A
$('#box').fadeOut() B
$('#box').disappear() C
$('#box').hide(1000) D
$('#box').slideOut()
Analysis & Theory
`$('#box').fadeOut()` fades out the element with id 'box'.
How do you handle a click event on a button with id 'submit'?
A
$('#submit').click(function(){ ... }); B
$('#submit').onClick(function(){ ... }); C
$('submit').on('click', function(){ ... }); D
$('submit').whenClick(function(){ ... });
Analysis & Theory
`$('#submit').click(function(){ ... });` attaches a click event to the button with id 'submit'.