作者fr730149 ()
看板Ajax
标题Re: [问题] JQuer_ not selector
时间Fri Sep 16 09:49:23 2011
感谢你的指导,的确是忽略效率的问题。
附带一提,下方语法少了一个 )
: $("th").each(function(){
: var $this = $(this);
if(!($this.contains("男人数")||$this.contains("女人数"))){
: $this.attr("rowSpan", 2);
: }
: });
执行後firebug报错: $this.contains is not a function
请问这要怎麽解决呢?
: 降写不是轻松多了吗 = = a
: 如果能改html,那就乾脆把需要上rowSpan 的或者不上rowSpan 的,
: 给个特定的class或attribute 直接用class或attribute来滤。
: 不要浪费时间再写一个很复杂很「丰富」的selector,
: 一是越复杂的selector 越慢,二是读起来越痛苦。
: 另外没有必要的话不要针对 "th" 这种大范围兵器操作,
: 小心以後改版需要增加table或者杀到自己画面上没必要的人。
: 帮table上个 id ex."userTable" ,
: 再操作 $("#userTable th") 效率也会好一点,风险也可以降低。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.125.235.184