html - jQuery append link text to another div -
jquery rookie, couldn't find documentation me answer following question:
i have list of filters , separate section display filters have been selected. i've figured out how append text target, can't figure out how grab filter names dynamically, e.g. click winter filter , "winter" displayed.
filter links html:
<div class="filter-dropdown"> <ul> <li class="filter complete" class="active" data-filter="all" data-dimension="season">all</li> <li class="filter individual" data-filter="m-winter w-winter a-winter" data-dimension="season">winter</li> <li class="filter individual" data-filter="m-fall w-fall a-fall" data-dimension="season">fall</li> <li class="filter individual" data-filter="m-summer w-summer a-summer" data-dimension="season">summer</li> <li class="filter individual" data-filter="m-spring w-spring a-spring" data-dimension="season">spring</li> </ul> </div>
filter display html:
<div class="filter-details"> <span class="filter-title">filters</span> <ul class="filters-current"> <!-- filter titles added , removed via jquery --> </ul> </div>
jquery:
$('.individual').on('click', function () { $('<li>filter name / </li>').appendto('.filters-current'); }); $('.complete').on('click', function () { $('.filters-current').empty(); });
in above, issue i'm trying resolve how replace "filter name" variable filter text.
if want text contained when clicked:
$('.individual').on('click', function () { $('<li>'+$(this).text()+'</li>').appendto('.filters-current'); });
$(this).text() gets contents of clicked element.
Comments
Post a Comment