8

I need to change the form action URL depending on the body class of the page. So far I have

$('document').ready(function () {
 if ($('body').hasClass('hosting')) {
      $('#quoteForm').attr('action', 'hostingURL');
      }
});

and that works perfectly. But I need to expand it to include more body classes. I tried

$('document').ready(function () {
 if ($('body').hasClass('hosting')) {
      $('#quoteForm').attr('action', 'hostingURL');
      }
 elseif ($('body').hasClass('workspace')) {
      $('#quoteForm').attr('action', 'workspaceURL');
      }
 else{}
});

but it isn't working. Any suggestions appreciated.

4
  • typo elseif a space between else if Commented Nov 30, 2012 at 3:14
  • Please try the answer here stackoverflow.com/questions/979024/… Commented Nov 30, 2012 at 3:14
  • You know people can just turn JavaScript off, right? Commented Nov 30, 2012 at 4:05
  • 6
    Only creeps turn off JavaScript Commented Dec 15, 2014 at 11:25

1 Answer 1

5

add white space in elseif like else if

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.