Lower and uppercase with click event

I would like to put a simple button text in uppercase when I clik, then to lowercase when I click to another button in the list.I have four differents buttons.

Here is my code from my view twig :

        <div class="btn-group btn-group-lg" role="group" aria-label="...">
            {% for s in secteur %}
                <button id="linkSecteur_{{ s.SecteurId }}" class="text-lg-left btn btn-link z-btn- 
                 secteur" data-id="{{ s.SecteurId }}">{{ s.LibLong }}</button>
            {% endfor  %}
        </div>

Here is my code in jquery in order to fix this issue :

   $('.z-btn-secteur').on('click', function() {
        if ($(this).data('change', 'true')) {
            //console.log('hello')
            $(this).addClass('text-uppercase');
        } else {
            $(this).addClass('text-lowercase');
        }
    });

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *