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
Post a Comment