Using jquery to change form action URL

forms, jquery

Solution

add white space in `elseif` like `else if`

Problem

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.

Original source

Related problems