当前位置:嗨网首页>书籍在线阅读

17-问题

  
选择背景色: 黄橙 洋红 淡粉 水蓝 草绿 白色 选择字体: 宋体 黑体 微软雅黑 楷体 选择字体大小: 恢复默认

5.4.1 问题

你有一个冗长的jQuery链,包含 .children().end() 之类的方法,处理多组相关的元素。很难看出哪个操作应用到哪些元素上:

$('#box').addClass('contentBox').children(':header')
   .addClass('contentTitle').click(function() {
     $(this).siblings('.contentBody').toggle();
   }).end().children(':not(.contentTitle)')
   .addClass('contentBody').end()
   .append('<div class="contentFooter"></div>')
   .children('.contentFooter').text('generated content');