Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

86
Vistas
Can I click the same gylphicon class and toggle between two functions?

Is it possible to click a glyphicon and toggle between two functions? I declared a glyphicon pencil here

var tgtEditLink = document.createElement("a");
        tgtEditLink.href = "#";
        tgtEditLink.setAttribute('aria-label', 'Edit');
        var tgtEdit = document.createElement("i");
            tgtEdit.classList.add("glyphicon", "glyphicon-pencil", "white", "tgt-edit");
            tgtEdit.title = "Edit";
        tgtEditLink.appendChild(tgtEdit);
    tgtDragbar.appendChild(tgtEditLink);

users can click this class to enable the "edit" function on my application. I then want to be able to click the same glyphicon and disable said function for another one.

    $(document).on('click', '.tgt-edit', function rearrange() {
    $('#align-src-col').sortable(sortableOptionsSrc);

    return false;
});

The above code will let users edit their text.

I want to be able to click the pencil again, '.tgt-edit', to disable edit, and enable another function. Is this possible in javascript?

Thank you!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can toggle the class of the element so it no longer has tgt-edit and has the class that the other operation is delegated to.

$(document).on('click', '.tgt-edit', function rearrange() {
    $('#align-src-col').sortable(sortableOptionsSrc);
    $(this).toggleClass(["tgt-edit", "tgt-other"]);
    return false;
});
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda