0

when I use these codes, the web is working well:

ComOperate.prototype.initop = function()
{
    var op_children = this.$element.find(".mikeoperate").each(function()
   {
   if($(this).attr("data-initstatus") == "hide")
   {
        $(this).hide();
   }
})

but if I use these codes,the web crash:

var op_children = this.$element.find(".mikeoperate").hide;
for(var pp in op_children)
{
   var p = $(op_children[pp]).attr("data-initstatus");
   if(p == 'hide')
   {
        $(op_children[pp]).hide();
   }
}

I don't know why

Rohan Kumar
  • 40,431
  • 11
  • 76
  • 106
  • `.find(".mikeoperate").hide` is a function reference.... what are you really trying to do here – Arun P Johny Jan 24 '14 at 04:40
  • possible duplicate of [JavaScript for...in vs for](http://stackoverflow.com/questions/242841/javascript-for-in-vs-for) – CRABOLO Jan 24 '14 at 04:40
  • 1
    from what I can see it should be as simple as `ComOperate.prototype.initop = function () { this.$element.find('.mikeoperate[data-initstatus="hide"]').hide(); }` – Arun P Johny Jan 24 '14 at 04:41
  • sorry, var op_children = this.$element.find(".mikeoperate") shuold be correct. It is a writing mistake. but the web also crash. The question is why I can not visite the web – user3230450 Jan 24 '14 at 04:47

1 Answers1

0

hide() is a function not property and replace for in to simple for like,

var op_children = this.$element.find(".mikeoperate");// remove hide from here
for(var pp=0,len=op_children.length;pp<len;pp++) {
   var p = $(op_children[pp]).attr("data-initstatus");
   if(p == 'hide') {
        $(op_children[pp]).hide();
   }
}

Live Demo

Rohan Kumar
  • 40,431
  • 11
  • 76
  • 106