2016-03-27 22 views
1

Muhtemelen basit bir soru ama jQuery girişinin adını yazdı nasıl:Girdi adı jQuery

HTML

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

JQUERY:

Bu iş gibi görünüyor değil veya hata başka bir yerde geçerli:

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

sen selektör –

+0

yazım hatası sonunda birini ']' eksik: 'jQuery ('input [name =" kullanıcı [ profile_attributes] [doğum tarihi (3i) ']') '' '' '' '' 'olmalıdır. https://jsfiddle.net/2sgetdpL/ (mevcut querySelector sizin girişiniz [name = ”kullanıcı [profile_attributes] [birthdate (3i)' yerine [input = ”kullanıcı [profile_attributes] [birthdate (3i)] ] ') – briosheje

+0

Teşekkürler tipo ve gizle() + diable, formda var göndermemek için true – Wordica

cevap

0

Sen olması gerektiği sizin J sorgu seçicisi bir yazım hatası var:

jQuery('input[name="user[profile_attributes][birthdate(3i)]"]') 
0
  1. Ayrıca bu

    <input type="hideen" name="VALUE" profile="VALUE" birthday="VALUE"> 
    
    için farklı Attribut

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

veri kaydedebilir

    Sonra
  1. ile jquery ile değerleri ayıklayın:

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

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

    var doğum günü = $ (this) .attr (doğum günü);

Ya ajax ile bir nesne olarak kaydedin:

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