Is it possble to do comparion of two variables in javascript of different types -


i having jstree , in javascript function checking node has been selected thats working fine. when assign node value variable comparasion normal string variable thats not working.

$(document).ready(function() {     $('#bdeviewnew').on('changed.jstree', function(e, data) {         var i, j, r = [];          (i = 0, j = data.selected.length; < j; i++) {               var x = data.instance.get_node(data.selected[i]).text;               r.push(data.instance.get_node(data.selected[i]).text);               if(x=="hadoop")                  {alert("hi");}             else{                 alert("hello");             }           }     });  }); 

any 1 know how can such comparasion?

thanks in advance

it possible variable has unexpected whitespace @ start or end, that's common problem. should able rid of with

var x = data.instance.get_node(data.selected[i]).text.trim(); 

should work on modern browsers.

also keep in mind javascript has function scope, not block scope might used c/c++ or java. x declare there visible throughout function, not in loop. should declare @ same time i, j , r.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -