JSFiddle - React, Tailwind, and code Playground

by Norlihazmey Ghazali

HTML

<div class="col-lg-12" align="center">
    <button type="button" class="btn btn-default" style="background-color:#CCC" id="guardar" value="Modificar">
        <img src="img/import.ico" height="25" width="25" \>Modificar</button>
    <br/>
    <br/>
</div>
<div class="col-lg-12" align="center">
    <button type="button" class="btn btn-default" style="background-color:#CCC" id="eliminar" value="Eliminar">
        <img src="img/export.ico" height="25" width="25" \>Eliminar</button>
    <br/>
    <br/>
</div>

JavaScript

$(document).on('click', "#guardar", function () {
    //alert("Entro a modificar");
    if ($(this).val() == "Modificar") {
        $(this).val("Guardar"); // change into $(this) and use .val()
        $(this).contents().filter(function(i,e){
            if ( this.nodeType == 3 && i == 2 )
                this.nodeValue = "Guardar";
        });
         //console.log( $(this).contents().get());
    } else {
        alert("Entro a guardar");
        $(this).val("Modificar"); // change into $(this) and use .val()
        $(this).contents().filter(function(i,e){
            if ( this.nodeType == 3 && i == 2 )
                this.nodeValue = "Modificar";
        });
        
    }
});