毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> WEB开发 >> 正文

父子关系的两个div都绑定了click,点击上面的就激活了下面的click,怎么控制

更新时间:2012-12-24:  来源:毕业论文

父子关系的两个div都绑定了click,点击上面的就激活了下面的click,怎么控制
目的:做一个文章列表,ajax添加了内容的基本机构是这样的<ul>年<li>月<ul><li>日</li></ul></li></ul>,要实现的功能是点击年出现月的列表,点击月出现日的列表,因为内容都是ajax添加,我用live绑定了年和月的click事件。问题如下:点击年出现了月列表,这是正常的,但点击月的时候,同时激发了父级年的click事件,日的列表一闪就没了,又变成了点击年后出现月的样子。这个问题有没有好的解决办法?
$(function() {     var date_type = "";     get_li();     function get_li() {         $.ajax({             type : "post",             dataType : "html",             url : "member/content_li.php",             data : {                 q_id : $("#qid").html(),                 date_type : date_type             },             success : function(res_year) {                 $("#date_li").html(res_year);                 var year = ""                $(".year").live("click", function() {                     year = $(this).html().substr(0,4);                     $.ajax({                         type : "post",                         dataType : "html",                         url : "member/content_li.php",                         data : {                             q_id : $("#qid").html(),                             date_type : "year",                             year : year                         },                         success : function(res_month) {                             $("li[year=" + year + "]").html(res_month);                             var month = ""                            $(".month").live("click", function() {                                 month = $(this).html().substr(0,2);                                 $.ajax({                                     type : "post",                                     dataType : "html",                                     url : "member/content_li.php",                                     data : {                                         q_id : $("#qid").html(),                                         date_type : "month",                                         year : year,                                         month : month                                     },                                     success : function(res_day) {                                         $("ul[month=" + month + "]").html(res_day);                                         $(".day").live("click", function() {                                             day = $(this).html().substr(0,2);                                             var date = year + "-" + month + "-" + day;                                             $.ajax({                                                 type : "post",                                                 dataType : "json",                                                 url : "member/content_li.php",                                                 data : {                                                     q_id : $("#qid").html(),                                                     date_type : "day",                                                     date : date                                                 },                                                 success : back_do11                                             })                                         })                                     }                                 })                             })                         }                     })                 })             }         })     }

要这么写啊,你可以把每个处理单独提出来变成一个函数,看起来就方便明了了

[1] [2] 下一页

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。