Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
76
rated 0 times [  82] [ 6]  / answers: 1 / hits: 18643  / 12 Years ago, tue, december 25, 2012, 12:00:00

Why doesn't the following code work?



        var err = document.getElementById(text-error).value;
if (err == Team already exists) {
$('#text-error').fadeIn(400).delay(3200).fadeOut(800);
}


The error does not fade in or fade out.



Checked the console - no problems.



Also, this particular error is sent via the server.



The fade in and fade out work for my client side errors - but not errors pertaining to my database like this one - if that makes any difference to the problem.






UPDATE



After console logging - I realize that it does not enter the if statement, even though it clearly equals it - via html code and via a quick glance at the page.


More From » javascript

 Answers
14

I am assuming you have something like



<div id=text-error> Team already exists </div>


If so, then replace your first line of code with



var err = document.getElementById(text-error).innerText;


JsFiddle - http://jsfiddle.net/fCNe8/


[#81239] Saturday, December 22, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
chyanne

Total Points: 208
Total Questions: 120
Total Answers: 110

Location: Colombia
Member since Mon, May 2, 2022
2 Years ago
;