Q
How to change the text content of all <h1> elements to 'New Heading' using jQuery?

Answer & Solution

Answer: Option C
Solution:
$('h1').text('New Heading');
Related Questions on Average

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 change the alt attribute of all <img> elements to 'New Image' using jQuery?

A). $('img').alt('New Image');

B). $('img').setAttribute('alt', 'New Image');

C). $('img').attr('alt', 'New Image');

D). $('img').setAttr('alt', 'New Image');

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 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');

Which jQuery method is used to change the height of all <div> elements to 200 pixels?

A). $('div').height('200px');

B). $('div').setHeight('200px');

C). $('div').css('height', '200px');

D). $('div').style('height', '200px');

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');

How to add the class 'active' to all<li> elements within a<ul> using jQuery?

A). $('ul li').setAttribute('class', 'active');

B). $('ul li').add('active');

C). $('ul li').addClass('active');

D). $('ul li').setAttribute('class', 'active');

Which jQuery method is used to change the background color of all paragraphs to yellow?

A). $('p').css('background-color', 'yellow');

B). $('p').style('background-color', 'yellow');

C). $('p').bgColor('yellow');

D). $('p').background('yellow');

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;