Wednesday 15 September 2010

Using || in a Jquery comparison -


Looks like I can not use || To compare something in my script, which I've done so far

  var original text = []; Var novice = 'novice' var intermediate = 'intermediate' var expert = 'expert' changes the text on // hover $ (function () ($ 'skill double click'). Hover (function () {original text [$ (This). Index ('skill double click')] = $ (this) .text (if;) (original text [$ (this). Index ('skills double li')] == 'selenium') {$ (This) .text (expert);} and if (original text [$ (this). Index ('skills. Double li')] == 'css') {$ (this) .text (intermediate) ;} And {$ (this) .text (newbie);}}, function () {$ (this) .text (original text [$ ( This). Index ('skill double click')]);});});   

So a simple task that I'm slipping on it and comparing it with that string depends on the string, which depends on the given string, it Hover will output a different string. if (original text [$ (this). Index ('skill double click')] == 'selenium' || 'jmtre')

function Will fail and all the circles will have text. .

How can I compare to many strings in this statement and if anyone has any suggestions on factoring, please share.

Any help appreciated

thanks

  = 'selenium' || 'jmtter')   

Should be typed like

  if (original text [$ (this). Index ('. Default form [$ (this). Index (' skill double double ')] ==' Jmter ')   

or better

  var original = original text [$ (this). ');; If (original ===' selenium '|| original ===' jmter ')   

always a Better idea is not to repeat yourself. Use === instead of == , where ever possible, as better than the latter half

No comments:

Post a Comment