首页 新闻 会员 周边 捐助

JQUERY级联操作绑定事件

0
悬赏园豆:5 [已解决问题] 解决于 2008-04-25 08:41
<A href="http://www.cnblogs.com/rene1018/archive/2008/04/21/jQuery-cascade-event-bind-trigger.html" target=_blank><FONT color=#810081>http://www.cnblogs.com/rene1018/archive/2008/04/21/jQuery-cascade-event-bind-trigger.html</FONT></A>
xiaohc的主页 xiaohc | 初学一级 | 园豆:23
提问于:2008-04-21 09:45
< >
分享
最佳答案
0
你好.你的问题我大致给你写了一个DEMO.如果你还有问题.可以给我留言.代码如下: ----universities.html---- <li id="1">Universities 01</li> <li id="2">Universities 02</li> ----course1.html---- <li id="Course01">University 01's Course 01</li> <li id="Course02">University 01's Course 02</li> ----course2.html---- <li id="Course01">University 02's Course 01</li> <li id="Course02">University 02's Course 02</li> ----demo.html---- //body <button type="button" id="btnTest">List Universities</button> <ul id="lstUniversities"></ul> <ul id="lstCourses"></ul> //script $(document).ready(function(){ $('#btnTest').click(function(){ $('#lstUniversities').load('universities.html', function(){ $("#lstUniversities > li").each(function(){ var currentUniversityID = $(this).attr('id'); $(this).click(function(){ $('#lstCourses').load('course' + currentUniversityID + '.html', function(){ $('#lstCourses > li').each(function(){ $(this).click(function(){ alert("You've chosen University " + currentUniversityID + "'s " + $(this).attr('id')); }); }); }); }); }); }); }); });
Kenneth Byron | 小虾三级 |园豆:570 | 2008-04-24 21:57
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册