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>
Written by Kenny Crippen
Related protips
1 Response
Alternatively, just use the .toggle(function(), function()) method.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jquery
Authors
Related Tags
#jquery
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#