Visual Programming MCQs with Answers
Practice important Visual Programming MCQs with answers and explanations.
Multiple Choice Questions
Q701: How can you change the source of an image with the ID banner using jQuery?
- A: $('#banner img').attr('src', 'images/newimage.png');
- B: $('#banner img').setSrc('images/newimage.png');
- C: $('#banner img').src('images/newimage.png');
- D: $('#banner img').updateSrc('images/newimage.png');
View Answer
A
Q702: Which jQuery method is used to remove an attribute from an element?
- A: .removeAttr()
- B: .removeProperty()
- C: .deleteAttr()
- D: .clearAttr()
View Answer
A
Q703: What does the mouseover event in jQuery do?
- A: It triggers when the mouse pointer moves over an element
- B: It triggers when the mouse pointer clicks on an element
- C: It triggers when an element receives focus
- D: It triggers when the mouse pointer leaves an element
View Answer
A
Q704: What does evt.preventDefault() do in jQuery event handling?
- A: It stops the default behavior of the event, like form submission or link navigation
- B: It sets a default value for the event
- C: It logs the event details to the console
- D: It stops the event from bubbling up the DOM tree
View Answer
A
Q705: How can you bind multiple events to an element using jQuery?
- A: $('#selector').bind('click mouseover', function() {});
- B: $('#selector').on('click mouseover', function() {});
- C: $('#selector').click(function() {}).mouseover(function() {});
- D: $('#selector').events('click mouseover', function() {});
View Answer
B
Q706: Which method is used to stop event bubbling in jQuery?
- A: evt.stopPropagation()
- B: evt.preventDefault()
- C: evt.stopImmediatePropagation()
- D: evt.cancelBubble()
View Answer
A
Q707: What is the purpose of $(document).ready() in jQuery?
- A: It ensures that the DOM is fully loaded before executing the code
- B: It binds events to elements as soon as they are created
- C: It prevents the document from reloading
- D: It executes the code immediately, bypassing DOM readiness
View Answer
A
Q708: How can you create a toggle effect for an element using jQuery?
- A: $('#element').toggle()
- B: $('#element').fadeToggle()
- C: $('#element').slideToggle()
- D: $('#element').showToggle()
View Answer
A
Q709: What is the effect of the slideDown() method in jQuery?
- A: It makes an element slide down into view
- B: It makes an element slide up out of view
- C: It hides an element with a sliding effect
- D: It toggles the visibility of an element with a sliding effect
View Answer
A
Q710: How can you animate multiple CSS properties at once in jQuery?
- A: $('#element').animate({left: '100px', opacity: 0.5}, 1000);
- B: $('#element').css({left: '100px', opacity: 0.5});
- C: $('#element').transition({left: '100px', opacity: 0.5}, 1000);
- D: $('#element').set({left: '100px', opacity: 0.5}, 1000);
View Answer
A