I need to compare two hex values that are coming from a xml tag attribute field, I’m trying this:
var fill = $(this).attr( "fill" );
// console.log( fill.toString(16) );
if ( fill === "#FF00FF" )
But is not working any ideas?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
attrreturns a string, there’s no need to calltoStringon it (and the argument will be ignored, becauseString‘stoStringdoesn’t take an argument).Your code is assuming a couple of things:
That the attribute comes back in #hex form (if it’s a color value, this is not reliably true cross-browser).
That it will be in all upper case.
Not knowing what you see when you log the value, I’ll just address the second part: