开发者

How to get form content by name?

开发者 https://www.devze.com 2023-03-06 15:03 出处:网络
If I have $(document).ready(function(){ $(\'form\').live(\'submit\', function(){ var dom= $(this); var all_forms = $(\"form\");

If I have

$(document).ready(function(){
    $('form').live('submit', function(){
    var dom       = $(this);
    var all_forms = $("form");

Problem

How do I get a specific form by name and not ID?

<form id="create_form" name="create_form" action="" method="post">

Purpose

The reason it have to be by name is that I have many auto-generated forms, where I don't know the ID's before hand, but the names are always the same.

When I have the form, I will pass it to a nested

$.ajax({
   type:开发者_如何学Go "GET",
   url: "/cgi-bin/ajax.pl",
   contentType: "application/json; charset=utf-8",
   dataType: "json",

// data: $(this).serialize(),
// data: $(form_id).serialize(),
// data: $(aform).serialize(),


You can use the attribute equals selector:

$('form[name="create_form"]')
0

精彩评论

暂无评论...
验证码 换一张
取 消