jquery - How to get clone html hidden id while clicks on cancel button -
i have clone html data here need delete 1 record need id cancel record. here html code:
<div id="allergies" class="clone"> <div class="copy"> <input type="hidden" id="allergyid" value=""> /*rest of code html data*/ <a class="addallergy" id="addallergy">save , add allergy</a> <a class="removeallergy" id="removeallergy">cancel</a> </div> <div>
here javascript code:
var p=$('.copy').length; var h=0; for(var i=0 ; i<data.allergies.length ; i++){ var cloned = $(".copy:first").clone(true) . .appendto('#allergies').addclass("childallergyclass" + (i + 1)); $(".childallergyclass"+ ++h+" #allergyid").val(data.allergies[i].allergyid); }
now html code be:
<div id="allergies" class="clone"> <div class="copy childallergyclass1"> <input type="hidden" id="allergyid" value="123"> /*rest of code html data*/ <a class="addallergy" id="addallergy">save , add allergy</a> <a class="removeallergy" id="removeallergy">cancel</a> </div> <div class="copy childallergyclass2"> <input type="hidden" id="allergyid" value="124"> /*rest of code html data*/ <a class="addallergy" id="addallergy">save , add allergy</a> <a class="removeallergy" id="removeallergy">cancel</a> </div> <div>
if have length 2 2 allergies displayed in ui.if click on cancel current record disappeared using code
$(".removeallergy").click(function(e) { $(this).closest(".copy").fadeout("slow", function(){ $(this).remove(); }); });
then need particular record id inactive current record status in database.
please me how id cancel record or else better idea inactive record in database.
i got answer: in project use similar id's , application works fine.
$(".removeallergy").click(function(e) { $(this).closest(".copy").fadeout("slow", function(){ var abc = $("#allergyid",this).val(); $(this).remove(); }); });
Comments
Post a Comment