0

jsfiddelI am using javascript replace() in my project, so i use this code

function addFloorPlan(ant){
    //var count = 
    $('#appendClass'+ant+'').after('<div id="appendClass'+ant+'" class="clearfix"><div class="col-md-4"><div class="form-group"><label>Name</label><input type="text" class="form-control" placeholder="Enter your file name" name="file_name'+ant+'[]"></div></div><div class="col-md-8"><div class="form-group"><label>Choose file</label><input name="file_img'+ant+'[]" type="file" style="margin-top: 8px;"><span class="glyphicon glyphicon-remove removeCss" aria-hidden="true" onclick="removeFloorPlan('+ant+');"></span></div></div></div>');
    var cnt = ant+1;
    document.getElementById('getCount').outerHTML.replace('addFloorPlan('+ant+')', 'addFloorPlan('+cnt+')');
}

Html content:

<button type="button" id="getCount" class="pull-right btn btn-primary btn-xs"  onclick="addFloorPlan(1);">Add another</button>

Actually i am replacing addFloorPlan(1) to addFloorPlan(2).....in this javascript when i check with alert its working, but this new text is not changing in html content. I am really struck on this please help me to overcome this issue. Thank you

Vijaykarthik
  • 333
  • 4
  • 10
  • 25
  • 5
    `String.prototype.replace()` returns the modified string. It does not change the string in-place. [MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) – Phylogenesis Jan 26 '15 at 15:03
  • Can you show it in a jsfiddle please – tylerlindell Jan 26 '15 at 15:05

0 Answers0