您的位置:首页 > Web前端 > JQuery

关于jquery 开发的几个问题

2011-12-27 17:38 155 查看
如何绑定 live 和 toggle 方法

无法直接使用,只能使用 $(yourhtml).is(":visiable") 来判断,如下是我的一个程序的一部分代码

//get comments for video
  $(".message_list").live("click", function(){
    var vid = $(this).attr("ref");
    var video_pane = $(this).parents(".video_pane");
    if(video_pane.children(".message").length == 0) {
      $.get(GET_MESSAGES_URL, {id: vid}, function(data){
        console.log(data);
        var options = {
          data: data,
        };
        var html = Application.base.generate_message_pane(options);
        console.log(html);
        video_pane.append(html);
      },"json");
    } else if($(video_pane.children(".message")[0]).is(':visible')){
      $(video_pane.children(".message")[0]).hide("slow");
    } else {
      $(video_pane.children(".message")[0]).show("slow");
    }

  });


需要注意的是, 一定要将dom 转换成 jquery 对象

dom -> $(dom)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: