【问题标题】:jQuery Form Action Change Not workingjQuery表单动作更改不起作用
【发布时间】:2011-02-26 01:56:44
【问题描述】:

有人知道为什么这个 sn-p 不能在最新版本的 Firefox 中工作吗? (在 Chrome 中正常工作)。

$("select[name='action']").live('change', function()
    {
        $(this).closest("form").attr('action', $(this).val());
        alert($(this).closest("form").attr('action'));
        //$(this).closest("form").submit();
    });

编辑 它也不适用于IE8。很奇怪。

HTML

<form method="post" action="#">
 <fieldset>
  <select style="width:95px" name="action" class="action">
   <option>Select</option>
   <option value="/user/account">Preview</option>
   <option value="/user/account/edit">Edit</option>
   <option value="/user/account/upgrade">Upgrade</option>
  </select>
 </fieldset>
</form>

【问题讨论】:

  • 请同时发布 HTML。也请详细描述症状。
  • @Mark Eirich - 症状?在 Chrome 中 alert() 根据选择显示正确的操作,在 FF 中显示 #,在 IE 中没有任何反应。

标签: jquery forms jqueryform


【解决方案1】:

这是一个命名冲突,给选择另一个名字。

表单有一个属性“action”和一个成员“action”(选择本身,因为它的名字是“action”)。

警报应该在 FF 中为您提供 [object HTMLSelectElement]form.attr('action') 指向 &lt;select/&gt;,而不是您喜欢访问的表单的操作属性。

【讨论】:

  • 谢谢,不知道有冲突。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-07-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-20
  • 2023-03-19
  • 1970-01-01
相关资源
最近更新 更多