Change icon

Change icon

Coder102Coder102 Posts: 78Questions: 2Answers: 0

Hello, I have a button with a fontaweasome icon, I would like to make that when I click it, it changes to another icon, can I do that?

Replies

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • Coder102Coder102 Posts: 78Questions: 2Answers: 0
    edited September 2020


    I do not want to have 2 buttons, I want that when I press the + symbol it changes to the symbol - and when I open the symbol - it changes to the + symbol

    My buttons

  • kthorngrenkthorngren Posts: 20,300Questions: 26Answers: 4,769
    edited September 2020

    In your click event use the jQuery toggleClass() method to change the font awesome classes.

    If you need help with this please build a simple test case so we can see everything you have.

    Kevin

  • Coder102Coder102 Posts: 78Questions: 2Answers: 0

    My buttons

    and the event
    Click
    My idea is that it has only one button and that when I touch it it changes the shape from + to -

  • kthorngrenkthorngren Posts: 20,300Questions: 26Answers: 4,769

    As I said, use toggleClass() in the click event. For example:
    http://live.datatables.net/xijecupo/279/edit

    Click the 'Name' button to see the class toggle.

    If you need help with this then please build a running test case (not code snippets).
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

This discussion has been closed.