Jquery只能在切换时单击一次

我使用以下脚本来显示不同的背景,具体取决于div的状态。

当它没有展开时,它显示“加号(+)”符号,而当展开时它没有背景图像(不显示任何内容)。

问题是只能工作一次,我不知道为什么。

这是代码:

编辑(添加HTML)!

HTML:

 
  • TITLE

    SUBCONTENT











  • TITLE

    SUBCONTENT











JS:

 $(document).ready(function() { $('.meta').click(function() { $(this).css('background', 'none'); }); $('.mix').click(function() { var collapse_content_selector = $(this).attr('href'); var toggle = $(this); $('.meta').click(function() { $(this).css('background', 'url(images/arrow_down.png) no-repeat scroll 95% 97% transparent'); }); $(collapse_content_selector).toggle(function() {}); }); }); 

(.mix值使Div扩展,.meta类切换到不同的背景)。

任何线索?

EDIT2(实例)

http://anubisfiles.com/test/test.html

(由于我对jsFiddle并不熟悉,我更愿意向您展示它在网站上托管的内容)。

谢谢!

使用函数来绑定事件,

 $('element').on('click', function() { }); 
 $('.mix').click(function() { var collapse_content_selector = $(this).attr('href'); var toggle = $(this); $(this).find('.meta').css('background', 'url(images/arrow_down.png) no-repeat scroll 95% 97% transparent'); $(collapse_content_selector).toggle(function() {}); }); 

试试这个