javascript - jquery help with next() function -


i have html markup looks this,

        </a>         <nav>             <ul>                 <li><a href=""><img src="/media/icons/view.jpg" alt="views"/> 210</a></li>                 <li><a href=""><img src="/media/icons/like.jpg" alt="likes"/> 45</a></li>                 <li class="jobs"><a href="">52 new jobs</a></li>             </ul>         </nav>         <ul class="job_listings">             <li><a href="">outbound telesales assistant &gt;</a></li>             <li><a href="">business development manager &gt;</a></li>         </ul     </li> 

the .job_listings hidden on dom ready , needs show when li.jobs a clicked, have tried following, jquery:

$('#jobwall .jobs a').click(function(){                 $(this).next('.job_listing').show();                 return false;             }); 

you should next element of nav element , not anchor, , missing s in .job_listing selector.

try this:

$('#jobwall .jobs a').click(function(){                      $(this).closest("nav").next('.job_listings').show();                      return false;              });  

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -