Colour the title of the article onclick


#1

Hello,

I wanted to test if i mastered the code for menu push and if i could incorporate a bit of it in the newsfeed.
More precisely, I want to animate the title of the article at clicking on it, and change its css property "color". Anyone could help me ?

https://www.codecademy.com/en/courses/web-beginner-en-4hxyb/0/3?content_from=make-an-interactive-website%3Ajquery-events#

Error message : Uncaught SyntaxError: missing ) after argument list


var main=function(){
    $(".article").click(function() {
    $(this).children('.description').show();
    };
    $(".article").click(function() {
        $(this).children('.title').animate({
        color:#ffffff;
        };
  ); 
};
$(document).ready(main);


#2

@kenzucky

I would try

var main=function(){
    $(".article").click(function() {
    $(this).children('.description').show().css(
        "color","#ff0000");
        
    });
    //(".article").click(function() {
    //    $(this).children('.title').animate({
    //    color:"#ff0000"
    //    });
    //});
};
$(document).ready(main);

#3

Try combining everything into the one handler. By having two click event handlers on the same object there is a conflict.

 $(".article").click(function() {
    $(this).children('.description').show();
    $(this).children('.title').animate({
        color:#ffffff;
    });
  });

Not sure we can animate color. Might have to read up on this. You could set a class in the stylesheet with the desired color property, then use .toggleClass() and .fadeTo().


#4

Thank you I appreciate your help. I'll post soon to show you my new code.


#5

Thank you leonhard, I like your nickname !


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.