jquery - how can I set only one text from <a attribute list? -


here, trying update input type attribute text only, if obj.idpartneroffice == json.idpartneroffice condition true. how can update project name ?

 if (json.idpartnerproject == "0") {                  json.idpartnerproject = math.random();                  hidjson.form5.projects.push(json);                  $("#divbindprojectlist").append('<a href="#" id="anchorproject1" class="list-group-item projectlist" >' + json.projectname + '<input type="hidden" name="hiddenproject1" class="hidprojectid" value="' + json.idpartnerproject + '" /></a>');              }              else {                  $.each(hidjson.form5.projects, function (i, obj) {                      if (obj.idpartnerproject == json.idpartnerproject) {                          hidjson.form5.projects[i] = json;                          $("#anchorproject1").html(json.projectname).append('<input type="hidden" name="hiddenproject1" class="hidprojectid" value="' + json.idpartnerproject + '" />');                      }                  });                  }

here image html view list of projects, enter image description here

now, hidden field values changed. how can fix it?

your best bet move hidden fields (which missing name attributes btw) outside of anchor tags (they're not clickable elements, anyway), add id attribute anchors:

<a href="#" id="anchorproject1" class="list-group-item projectlist">asdfasd</a> <input type="hidden" name="hiddenproject1" class="hidprojectid" value="12345" /> 

and use jquery access text:

$("#anchorproject1").html("aaaaaa"); 

edit:

you're in danger of having question flagged closure - started off asking how change text in anchor tag, , you're asking hidden fields? make mind - need with?


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -