arrays - jQuery each call to other function -


i curious why not work. more hypothetical did run issue on site doing. trying avoid jquery function inside function. selector window instead of each of boxes.

edit*** understand how doing $(".box").each(function(){ // code here }); not sloppy or bad practice functions inside of functions?

http://jsfiddle.net/b8yp3/3/

css

.box {     height: 50px;     width: 50px;     background: green;     margin-bottom: 5px; } 

html

  <div class="box"></div>     <div class="box"></div>     <div class="box"></div> 

javascript

 function changeme(obj) {         console.log(obj);         $(obj).css("background", "blue");     }      $.each($(".box"), changeme(this)); 

second each paramater must function - not function result:

$(".box").each(changeme);  function changeme(n, obj) { ........ 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -