Last Updated: February 25, 2016
·
1.196K
· kennycrippen

jQuery: Swap out some text with other text on click

jQuery Code:

$('div.dropdown ul li a').bind("click touch", function (){
    $('li.filtertext span').text( $(this).text() );
});

HTML:

<ul>
    <li class="filtertext"><span>Menu</span></li>
</ul>

<div class="dropdown" style="display: none;">
<ul>       
    <li><a href="#">Some Text</a></li>

    <li><a href="#">Some Other Text</a></li>
</ul>

</div>

1 Response
Add your response

Alternatively, just use the .toggle(function(), function()) method.

over 1 year ago ·