使用jquery更改表单操作URL

时间:2012-11-30 03:08:56

标签: jquery forms

我需要根据页面的正文类更改表单操作URL。到目前为止我已经

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

这完美无缺。但是我需要扩展它以包含更多的身体类。我试过了

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

但它不起作用。任何建议表示赞赏。

1 个答案:

答案 0 :(得分:5)

elseif中添加空白,例如else if