Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

84
Views
¿Puedo hacer clic en la misma clase de gylphicon y alternar entre dos funciones?

¿Es posible hacer clic en un glyphicon y alternar entre dos funciones? Declaré un lápiz de glyphicon aquí.

 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);

los usuarios pueden hacer clic en esta clase para habilitar la función "editar" en mi aplicación. Luego quiero poder hacer clic en el mismo glyphicon y deshabilitar dicha función para otra.

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

El código anterior permitirá a los usuarios editar su texto.

Quiero poder hacer clic en el lápiz nuevamente, '.tgt-edit', para deshabilitar la edición y habilitar otra función. ¿Es esto posible en javascript?

¡Gracias!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede alternar la clase del elemento para que ya no tenga tgt-edit y tenga la clase a la que se delega la otra operación.

 $(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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!