Jquery - Next div when clicking on a link

Asked

Viewed 298 times

1

I have 2 Divs and when I click inside a link inside the 1st div I need to get the value of the 2nd div, how do I do this?

HTML:

<div class="vei">
    <span class="download"><a target="_blank" href='teste2.php'>download</a></span>
</div>
<div class="titulo"><a target="_blank" href='teste.php'>Teste</a></div>

JS (I tried this but it didn’t work):

$( ".download a" ).click(function(e){
    $( ".download a" ).html($( ".titulo a" ).text(););
});

The "a" has to become "Test" and no more "download"!

  • See if it helps you: http://www.w3schools.com/jquery/jquery_ref_traversing.asp

2 answers

2


1

You put 2 ;(dot and comma)

Substitute

$( ".download a" ).click(function(e){
    $( ".download a" ).html($( ".titulo a" ).text(););
});

For

$( ".download a" ).click(function(e){
    $( ".download a" ).html($( ".titulo a" ).text());
    return false;
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.