javascript - how to make data as hidden -



javascript - how to make data as hidden -

i m getting info server in json.i want send sid response other function dont want display in browser. tried still showing on browser. js

$.each(responseobj.all.r,function(i){ $('#ref').append( '<li>'+'<input type=hidden id="refid">'+responseobj.all.r[i].rid+'</input>'+ '<input type="button" id="accept" value="accept">'+'</input>'+'</li>'); });

here onclick function take button

$("input[id^=accept]").click(function () { var p = $(this).closest('li').find('input[id^=refid]').text(); alert(p); localstorage.setitem("refid",p); var need=localstorage.getitem("refid"); accept(need); });

so in output dont want show refid ,i want send in take function.thanks in advance.

input elements void element code invalid,

'<input type=hidden id="refid">'+responseobj.all.r[i].rid+'</input>'

so seek replace code this,

'<input type=hidden id="refid" value="'+ responseobj.all.r[i].rid +'"></input>'

note: id should unique . in context have utilize same id id="refid" ,id="accept" in each loop .so seek avoid .instead of have use class

asking new question getting input hidden value

$("#ref").on("click", "[type=button]", function () { alert( $(this).closest('li').find('input[type="hidden"]').val()); }); demo

javascript jquery

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -