Answer & Solution
$('img').attr('src', 'newimage.jpg');
<img>
element using jQuery?
$('img').attr('src', 'newimage.jpg');
How to change the text content of all <h1>
elements to 'New Heading' using jQuery?
A). $('h1').html('New Heading');
B). $('h1').textContent = 'New Heading';
C). $('h1').text('New Heading');
D). $('h1').innerText('New Heading');
How to remove the href attribute from all anchor elements using jQuery?
A). $('a').removeAttr('href');
B). $('a').removeAttr('href');
C). $('a').deleteAttr('href');
D). $('a').removeAttribute('href');
How to change the color of all paragraphs to red using jQuery?
A). $('p').style('color', 'red');
B). $('p').css('color', 'red');
C). $('p').color('red');
D). $('p').setColor('red');
Which jQuery method is used to change the font weight of all<h2>
elements to bold?
A). $('h2').style('font-weight', 'bold');
B). $('h2').fontWeight('bold');
C). $('h2').css('font-weight', 'bold');
D). $('h2').bold();
Which jQuery method is used to change the opacity of all <div>
elements to 0.5?
A). $('div').setOpacity(0.5);
B). $('div').opacity(0.5);
C). $('div').css('opacity', 0.5);
D). $('div').opacity = 0.5;
Which jQuery method is used to change the background image of all <div>
elements?
A). $('div').bgImage('url(image.jpg)');
B). $('div').css('background-image', 'url(image.jpg)');
C). $('div').background('url(image.jpg)');
D). $('div').setImage('url(image.jpg)');
Which jQuery method is used to add the class 'highlight' to all <div>
elements?
A). $('div').addClass('highlight');
B). $('div').class('highlight');
C). $('div').attr('class', 'highlight');
D). $('div').applyClass('highlight');
Which jQuery method is used to set the value of the title attribute to 'New Title' for all elements?
A). $('a').attr('title', 'New Title');
B). $('a').title('New Title');
C). $('a').setAttribute('title', 'New Title');
D). $('a').titleAttr('New Title');
Which jQuery method is used to change the width of all <div>
elements to 300 pixels?
A). $('div').width('300px');
B). $('div').setWidth('300px');
C). $('div').css('width', '300px');
D). $('div').style('width', '300px');
How to remove the class 'hidden' from all elements with the class 'element' using jQuery?
A). $('.element').removeClass('hidden');
B). $('.element').remove('hidden');
C). $('.element').deleteClass('hidden');
D). $('.element').removeClassName('hidden');