`
ifox
  • 浏览: 61740 次
社区版块
存档分类
最新评论

jQuery如何判断某个对象有无某个属性

 
阅读更多

   var scopeList = '<s:property value="listEntity.strChangeScope"/>';

        var scope = scopeList.split("^");
        if (scope.length > 0) {
             for ( var i = 0; i < scope.length; i++)  {
                     if(scope[i]=='01'){                
                             $("#enName").removeAttr("style");        
                     }else if(scope[i]=='02'){                
                             $("#enReAdress").removeAttr("style");
                     }else if(scope[i]=='03'){                
                             $("#enEconomicProperty").removeAttr("style");
                     }else if(scope[i]=='04'){
                             $("#enSupplyScope").removeAttr("style");        
                     }
           }
      }
      if((typeof($("#enName").attr("style"))!="undefined")&&(typeof($("#enReAdress").attr("style"))!="undefined")&&(typeof($("#enEconomicProperty").attr("style"))!="undefined")&&(typeof($("#enSupplyScope").attr("style"))!="undefined")) {
                   $("#message").removeAttr("style");
     }
 

 

上面是源码,这段代码的功能是查看变更范围scopt内有没有值,默认所有内容都是隐藏的,如何scopt有值的话就删除掉其相应的style属性(这个属性包含了隐藏)。如果没有变更,也就是scope为空,就显示message里面的内容。主要代码已经用红色字符标记出来了。本来想用jquery来写,只可惜不会,只能用这种方法。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics