0

Using jQuery, how do I change the color of all paragraph tags on the page to green when a button is clicked? I've started with this:

$(document).ready(function() {
    button.click(function() {
 WHAT GOES HERE?     
    });
});
1
  • 1
    What you've already tried?? Commented Feb 24, 2014 at 20:28

3 Answers 3

1
<style>
.green{
   color: green;
}
</style>


$( "p" ).addClass( "green" );
Sign up to request clarification or add additional context in comments.

Comments

0

Something like this

$(document).ready(function() { 
    $('button').on('click', function() { 
       $('p').css('color', 'green');
    }); 
});

You should start by reading the manual -> https://learn.jquery.com/

Comments

0
$(document).ready(function() {
    $('button selector').click(function() {
        $('p').attr('style','color: green;');
    });
});

This should do the trick

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.