javascript - Replacing html button with jquery -
javascript - Replacing html button with jquery -
i've done research regarding on how replace/change original html button another. neither ways working.
here codes:
javascript:
var editbtn = "editbtn" + id; //in order id of edit button var csave = document.getelementbyid(editbtn); csave.innerhtml = "<td><button id='savebtn' onclick='savechange(" + id + ");' >save</button></td>";
the code above adding button within existing button.
html:
<table> <td> <% out.println("<button id='editbtn" + mc.getid() + "' onclick='editmc(this.id);'>edit</button>"); %> </td> </table>
the mc.getid() method "id".
the latest approach i've tried mentioned below, it's not working:
document.getelementbyid(editbtn).onclick = function() {savechange(id)};
and:
$(document).ready(function () { $("#editbtn").replacewith("<td><button id='savebtn' onclick='savechange(" + mcid + ");' >save</button></td>"); });
anyhow can alter edit button save button while onclick() performed?
you can alter text of button edit save using innerhtml. putting html within button element. seek
var csave = document.getelementbyid(editbtn); csave.innerhtml = "save"; csave.onclick = function() {savechange(id)};
javascript jquery html
Comments
Post a Comment