Link to home
Start Free TrialLog in
Avatar of Refael
RefaelFlag for United States of America

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 ..... :-)


$("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();
		});
	});

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Duy Pham
Duy Pham
Flag of Viet Nam image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Refael

ASKER

Hi Duy Pham

For some reason the script is not working when else should execute.
Avatar of Refael

ASKER

Thank you Duy Pham.

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?
Avatar of Refael

ASKER

Hello Duy Pham,

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
                       });
                }
	});

Open in new window