Mehrnoosh
Mehrnoosh

Reputation: 899

If is not working in javascript-meteor

I have a piece of code on click event for set a session variable. The console log in working in event click, but it doesn't go inside if condition:

      'click .family': function(event) {
        event.preventDefault();
        console.log('in change'); // result in change
        $("#btnFamily").html(event.target.text);

        var role = event.target.text;
        console.log('role',role); //result role  Fils

         if(role == "Fils"){
             console.log('here in son'); //never comes here
             Session.set('family', "Son");  //never comes here
         }

    },

Upvotes: 0

Views: 54

Answers (1)

Anand Singh
Anand Singh

Reputation: 26

if you are using Javascript then use role.trim()=='Fils' and if using jQuery then use $.trim(role)=='Fils'

you can use triple equal(===) operator for strict validation

i think this will be helpful..

Upvotes: 1

Related Questions