javascript - Jquery click only work once on toggle -


i using following script show different background depending on state of div.

when not expanded shows "plus (+)" sign, while when expanded not have background image (does not shows anything).

the problem there work once, , dont know why.

here's code:

edit (added html)!

html:

<body>     <section>         <div class="wrapper wf">             <ul id="parks" class="just"> <!--------------- product -->                 <li class="mix" href="#therapy_vital" >                 <div class="meta name">                         <div class="img_wrapper">                             <img src="images/spa/masaje/.jpg" onload="imgloaded(this)"/>                         </div>                         <div class="titles">                             <h2>title</h2>                         </div>                     </div>                     <!-- expand -->                     <div href="#therapy_vital" class="nav-toggle"></div>                     <div id="therapy_vital" style="display:none">                 <article class="ac-small">                  subcontent<br><br><br><br><br><br><br><br><br><br><br><br>                  </article>                 </div>                 </li>  <!--------------- product -->                 <li class="mix" href="#therapy_natur" >                 <div class="meta name">                         <div class="img_wrapper">                             <img src="images/spa/masaje/.jpg" onload="imgloaded(this)"/>                         </div>                         <div class="titles">                             <h2>title</h2>                         </div>                     </div>                     <!-- expand -->                     <div href="#therapy_natur" class="nav-toggle"></div>                     <div id="therapy_natur" style="display:none">                 <article class="ac-small">                  subcontent<br><br><br><br><br><br><br><br><br><br><br><br>                  </article>                 </div>                             </li>  </ul> </div>                               </section>     </body> 

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() {});     }); }); 

(the .mix value makes div expands, , .meta class switch different background).

any clue?

edit2 (live example)

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

(due not familiar jsfiddle, prefer show hosted on website).

thanks!

use on function bind events,

$('element').on('click', function() {  }); 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -