Q
How to change the color of all paragraphs to red using jQuery?

Answer & Solution

Answer: Option B
Solution:
$('p').css('color', 'red');
Related Questions on Average

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 font size of all elements to 16 pixels using jQuery?

A). $('span').style('font-size', '16px');

B). $('span').fontSize('16px');

C). $('span').css('font-size', '16px');

D). $('span').font('16px');

How to change the src attribute of an<img> element using jQuery?

A). $('img').attr('src', 'newimage.jpg');

B). $('img').src = 'newimage.jpg';

C). $('img').setAttribute('src', 'newimage.jpg');

D). $('img').srcAttr('newimage.jpg');

How to change the font family of all<p> elements to 'Arial' using jQuery?

A). $('p').style('font-family', 'Arial');

B). $('p').fontFamily('Arial');

C). $('p').css('font-family', 'Arial');

D). $('p').font('Arial');

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 HTML content of all <div> elements?

A). $('div').innerHtml('

New paragraph

');

B). $('div').html('

New paragraph

');

C). $('div').innerHTML('

New paragraph

');

D). $('div').setContent('

New paragraph

');

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

How to set the value of the placeholder attribute to 'Enter text' for all <input> elements using jQuery?

A). $('input').placeholder('Enter text');

B). $('input').setAttribute('placeholder', 'Enter text');

C). $('input').attr('placeholder', 'Enter text');

D). $('input').attr('placeholder', 'Enter text');

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;

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