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

94
Views
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 answers
Answer question

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 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!