vendredi 7 février 2020

Javascript indexOf not return exact value, any solution?

Please, how to add multiple queries and return only the exact value?

    if( placeholder.indexOf('Document') != -1 ){
        $(this).addClass('cpf');
    }
    if( placeholder.indexOf("Document B") != -1 ){
        $(this).addClass('cnpj');
    }
    if( placeholder.indexOf("Document A and B") != -1 ){
        $(this).addClass('cpf_cnpj');
    }

If my placeholder is "Document A and B", return only the class "cpf_cnpj" and not all classes.

Thank you very much!

Aucun commentaire:

Enregistrer un commentaire