So I have two different buttons:
<input type='button' class='EditData btn btn-warning' value='Edit' name="{{id}}">
<input type='button' class='AddNew btn btn-success' value='Add Allocation' id="{{id}}">
This is my JQuery
$(function () {
$('.AddNew').click(function(){
console.log(this.name);
});
$('.EditData').click(function() {
var y = document.getElementById("location_"+this.name);
y.innerHTML = '<input type="button" class="AddNew btn btn-success" value="Add Allocation" id="'+this.name+'">'
});
});
AddNew just prints something to the console. EditData replaces the EditData button with an AddNew Button.
AddNew works successfully. EditData successfully replaces itself with an AddNew button, however this button doesn't not work as intended and doesn't print anything on console when clicked.