论坛首页 Web前端技术论坛

jquery学习之—构建功能型表单(一)

浏览 28750 次
该帖已经被评为良好帖
作者 正文
   发表时间:2009-06-18  
I LOVE ice-cream
0 请登录后投票
   发表时间:2009-07-08   最后修改:2009-07-08
不错,学习下,对CHECKALL做了一些改进。
就是不要用each:

     function checkall() {      

            var heading = $("legend").remove().text()+'abc';
$("<h3></h3>").text(heading).prependTo("fieldset:last");

$("<li></li>").html("<label for='discover-all'><input type='checkbox' id='discover-all2'/><em>Check all</em></label>").prependTo("li.discover > ul");

            $('<span id=checkfx>反选</span>').appendTo($('#discover-all2').parent());

$("#discover-all2").click(function(){
var $checkboxes = $(this).parents("ul").find(":checkbox");
if(this.checked){
$(this).next().text("un-check all");
$checkboxes.attr("checked","true");
}
else{
$(this).next().text("check all");
$checkboxes.attr("checked","");
}
}).parent("label").css({"border-bottom":"1px solid #ccc","color":"#777","line-height":"2"});

            //$('<span id=checkfx>反选33</span>').appendTo($('#discover-all2').parent());

           
              $('#checkfx').click(function() {
                         
                           $("fieldset:last input[type='checkbox']").not( $("#discover-all2")[0] ).each(function(){ 
                                  if($(this).attr("checked")){ 
                                     $(this).attr("checked",false); 
                                   }else{ 
                                        $(this).attr("checked",true); 
                                    } 
                           }); 
                         
                      } 

                );

    }
0 请登录后投票
   发表时间:2009-07-14  
je的验证做的就不错,能不能讲下
0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics