javascript - Make DIV clickable with 2 or more links -


i have difficulties jquery. need madiv or section clickable (add link block element) , implemented code

$(document).ready(function() {         $(".clickable").click(function(){             window.location=$(this).find("a.slide-link").attr("href");             return false;         });     }); 

but when block has 2 or more links - links in block don't work correctly. redirect a.slide-link url.

how can solve issue? thanks!

update

<section class="clickable">     <div>         <div class="description">             <ul>                 <li>lorem ipsum</li>                 <li>lorem ipsum</li>                 <li>lorem ipsum</li>                 <li>lorem ipsum <a href="http://url1.com">here</a></li>             </ul>         </div>         <a class="slide-link" href="http://url2.com">url2</a>     </div> </section> 

if it's links want work within section, not clicking section itself, can use following:

$(document).ready(function() {     $(".clickable a.slide-link").click(function(){         window.location=$(this).attr("href");         return false;     }); }); 

though if you're planning on doing other going address, in case above code same having no code..

if want outer section link itself, you'd better using <a> tag too, , setting display: block. can't nest anchor tags within other anchor tags obvious reasons.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -