Refael
asked on
if in return statement
Hello Experts,
In the code below i am trying to include an if statement so if it returns any of the given strings (e.g. 07, 17) then hide "seb" and show "tos" BUT if not then do something else....
The problem is i am always getting an error while trying to include the "IF" right after the "return" I am guessing it is the wrong place or i should learn JavaScript better :-)
Any help ..... :-)
In the code below i am trying to include an if statement so if it returns any of the given strings (e.g. 07, 17) then hide "seb" and show "tos" BUT if not then do something else....
The problem is i am always getting an error while trying to include the "IF" right after the "return" I am guessing it is the wrong place or i should learn JavaScript better :-)
Any help ..... :-)
$("table tr td").each(function() {
$(this).filter(function() {
var thisText = $(this).text();
return thisText == "07" || thisText == "17"
}).parent().hover(function() {
$(".hause-seb").hide();
$(".house-tos").show();
});
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Duy Pham.
I just needed to include the function again inside the else for it to work :-)
Thank you!
I just needed to include the function again inside the else for it to work :-)
Thank you!
What was the issue with else? Have you managed to get it to work?
ASKER
Hello Duy Pham,
I only needed to include the function once more right after the "else"... :-) Thank you!
I only needed to include the function once more right after the "else"... :-) Thank you!
$("table tr td").each(function() {
var thisText = $(this).text();
if (thisText == "07" || thisText == "17") {
$(this).parent().hover(function() {
$(".hause-seb").hide();
$(".house-tos").show();
});
}
else {
$(this).parent().hover(function()
// do something else when text is not 07 or 17 here
});
}
});
ASKER
For some reason the script is not working when else should execute.