using $(this).each inside a plugin not working jquery -


i have simple plugin $(this).each() not working, calls once instead of onve each of selector $("input.[class~='checking']") bascailly want call each once each input box class of "checking" , totally lost why not working

(function ($) {     moshclass = ''     $.fn.ischeckedmo = function (moshclass) {         $("input.[class~='" + moshclass + "']").hide();           $(this).click(function () {             var amchecked = 0              $(this).each(function () {                  if (this.checked == true) {                     alert('am:' + amchecked)                     amchecked = amchecked + 1                 }             });             if (amchecked > 0) {                  $("input.[class~='" + moshclass + "']").show();             } else {                 $("input.[class~='" + moshclass + "']").hide();             }         });     } })(jquery); 

this solved below, getting lot of responses, appreciated lot wanted me assign $(this) variable use variable instead of $(this) in each() run. worked doing , putting variable inside $(myselector) parantheses , not inplace of entire section.

(function($) { moshclass=''  $.fn.ischeckedmo=function(moshclass) {  $("input.[class~='"+moshclass+"']").hide();     $("td.[class~='"+mohtml+"']").addclass('red')    var myselector=$(this)   $(this).click(function(){   var amchecked=0      $(myselector).each(function(){    if (this.checked==true) {      amchecked=amchecked+1}   }); if (amchecked>0)   {   $("input.[class~='"+moshclass+"']").show();   }else {   $("input.[class~='"+moshclass+"']").hide();    }  }); } 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -