Change icon

Change icon

Coder102Coder102 Posts: 57Questions: 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: 9,822Questions: 0Answers: 1,629

    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: 57Questions: 2Answers: 0
    edited September 11


    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: 10,638Questions: 25Answers: 2,428
    edited September 11

    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: 57Questions: 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: 10,638Questions: 25Answers: 2,428

    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

Sign In or Register to comment.