I created and if else statement to reflect appropriate specific text, I have a Jfiddle set up here: http://jsfiddle.net/heykate/osvg4h33/
What I am trying to accomplish, is depending if a user is logged in or not the text will change from Sign In or Create Account (if Welcome Guest) or say Sign Out (if logged in, ie: Welcome Friend).
HTML:
<div class="welcome"> Welcome Guest <span class="acctLink"> </span></div>
<div class="welcome"> Welcome Friend <span class="acctLink"> </span></div>
JQUERY:
if ($('.welcome:contains("Guest")').length > 0)
{
$("span.acctLink").html("Sign In Or Create An Account");
}
else
{
$('span.acctLink').html("Sign out");
}
In JSFiddle, it is validating the script, but the parenthesis' around the else statement are highlighted green.
Follow Up
Thanks guys for the help I was able to get the jquery to work just as expected, and how I needed it to work. Again, thank you for all the help, here is my final solution (probably a better way to do this - feedback is always welcomed):
HTML:
<div class="welcome">Welcome %%GLOBAL_CurrentCustomerFirstName%% (<span class="customerMenu"> </span>)</div>
JQUERY:
$('.welcome').each(function () {
if ($(this).is(':contains("Guest")')) {
$(this).find("span.customerMenu").html('<a href="/login.php">Sign In<a/> Or <a href="/login.php?action=create_account">Create An Account</a>');
} else {
$(this).find('span.customerMenu').html('<a href="/login.php?action=logout">Sign out</a>');
}
});