javascript - Error in Jquery function "output html is not a function" -


i have code print out list of users, when try run error:

uncaught typeerror: ".output".html not function,

what doing wrong here? or suggestions helpful.

note: tested using console.log, results want.

html code:

<html> <body> <div class="output">show output</div> </body> </htm> 

jquery code:

$(document).ready(function (){       $.getjson("http://zadanie.laboratorium.ee/users.json",function(data)      {          var items = [];          var number_of_user = 0;          var number_of_active_user = 0;          var number_of_active_men = 0;          var number_of_active_women = 0;             $.each(data,              function(key, value)              {               number_of_user += 1;               if(value['active'] == true){                  if(value['gender'][0] == 'female' || value['gender'][0] == 'female'){                     number_of_active_women +=1;                  }                  else if(value['gender'][0] == 'male' || value['gender'][0] == 'male'){                     number_of_active_men +=1;                  }               }               });                (".output").html("number_of_user ==> "+number_of_user +" number_of_active_user ==> "+ number_of_active_user +" number_of_active_men ==> "+ number_of_active_men +" number_of_active_women ==> "+ number_of_active_women);       });    });  

you're missing $ @ start of ('.output').

$(document).ready(function (){       $.getjson("http://zadanie.laboratorium.ee/users.json",function(data)      {          var items = [];          var number_of_user = 0;          var number_of_active_user = 0;          var number_of_active_men = 0;          var number_of_active_women = 0;             $.each(data,              function(key, value)              {               number_of_user += 1;               if(value['active'] == true){                  if(value['gender'][0] == 'female' || value['gender'][0] == 'female'){                     number_of_active_women +=1;                  }                  else if(value['gender'][0] == 'male' || value['gender'][0] == 'male'){                     number_of_active_men +=1;                  }               }               });              // added jquery $ here              $(".output").html("number_of_user ==> "+number_of_user +" number_of_active_user ==> "+ number_of_active_user +" number_of_active_men ==> "+ number_of_active_men +" number_of_active_women ==> "+ number_of_active_women);       });    });  

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -