Molly Campbell
Molly Campbell

Reputation: 439

Using jquery to change form action URL

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.

Upvotes: 8

Views: 20328

Answers (1)

mattn
mattn

Reputation: 7733

add white space in elseif like else if

Upvotes: 5

Related Questions