Wardy_7 Posted February 21, 2013 Share Posted February 21, 2013 Hi, I have some code that I want to include an "or" option into the code but not having much luck with it. if(anchorSrc.match("mysite.co.uk")&&anchorVal.match("Great Site")) Basically the above code makes sure that a link to mysite.co.uk is in place and that it uses the link text "Great Site". What I want to do is add that the "anchorVal.match" can be "Great Site" OR "Super Site" if that makes sense but I'm not having much luck with it. Any help would be appreciated, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/274773-adding-an-or-to-javascript/ Share on other sites More sharing options...
kicken Posted February 21, 2013 Share Posted February 21, 2013 || is the operator to use for a logical-or condition. As in Cond1 || Cond2. So just create a second anchorVal.match test and stick it after the current one and put a || between them. You also want to surround the whole condition (both anchorVal tests) in parenthesis to make sure everything is evaluated in the proper order. Quote Link to comment https://forums.phpfreaks.com/topic/274773-adding-an-or-to-javascript/#findComment-1413951 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.