loops - jQuery throwing up "Unexpected token for" as an error -


i have absolutely no idea problem is, following throws "unexpected token for" on loop below.

removing loop causes closing }; called unexpected token.

$.fn.appext = function() {          $(data).find('a').each(function() {                  fileext = this.href.replace(window.location, '').replace('localhost/program/code', '').split('.')[1];                  if ($.inarray(fileext, ext) == -1 && typeof fileext !== 'undefined') {                     ext.push(fileext);                 }              }              // here lies problem apparently             (i = 0; < ext.length; i++) {                 $('#ext').append('<h5>' + ext[i] + '</h5>');             }          }; 

you need add ); close call .each(), add var keywords aren't creating global variables:

$.fn.appext = function () {     $(data).find('a').each(function () {         var fileext = this.href.replace(window.location,             '').replace('localhost/program/code', '').split('.')[1]; // [1] added "var"          if ($.inarray(fileext, ext) == -1 && typeof fileext !== 'undefined') {             ext.push(fileext);         }     }); // [2] added ");"      (var = 0; < ext.length; i++) { // [3] added "var"         $('#ext').append('<h5>' + ext[i] + '</h5>');     } }; 

you should neatly indent code intent clearer.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -