lundi 6 janvier 2020

How to change ANY text when click on it? jQuery

I want any text on the site to change to 'Ok!' when I click on it.

enter image description here enter image description here

I tried using this code:

if($('*').text() != ''){
    $(this).click(function(){
        $(this).text('Ok!');
    });
}

But it does not work because if the text is in a div it changes when I click anywhere in div, but I need that only when I click on the text.




Aucun commentaire:

Enregistrer un commentaire