简体   繁体   中英

Input name in jQuery

Probably simple question but how wrote name of input in jQuery:

HTML

<input type="hidden" name="user[profile_attributes][birthdate(3i)]" value="3">

JQUERY:

This doesn't seems to work or bug is somewhere else:

jQuery('input[name="user[profile_attributes][birthdate(3i)"]')

您的J查询选择器中有一个错字,应该是:

jQuery('input[name="user[profile_attributes][birthdate(3i)]"]')
  1. Also you can save the data in different's attribut

     <input type="hidden" name="user[profile_attributes][birthdate(3i)]" value="3"> 

for this

<input type="hideen" name="VALUE" profile="VALUE" birthday="VALUE">
  1. Then, with jquery, extract the values with:

    var name = $(this).attr(name);

    var profile= $(this).attr(profile);

    var birthday = $(this).attr(birthday);

Or save it as an object with ajax:

var data = {name:$(this).attr(name), profile:$(this).attr(profile), birthday:$(this).attr(birthday)};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM