There are a number of elements in which you need to find all the phrases starting with #
For example, here is the html code itself:
<div id="gallery"> <span class="portfolio-desc">Текст для примера #test_test1 #test2</span> <span class="portfolio-desc">Текст для примера #test2</span> <span class="portfolio-desc">Текст для примера #test_test1 #test_test5 #test2</span> </div> It is necessary to find all the phrases beginning with # without repetitions. Those. The script should output the following array:
('#test_test1', '#test2', '$test_test5') I tried to do this in a similar way, but I could not understand the regulars:
var elementText = []; var a; $('#gallery span').each(function(i, selected){ if($(selected).text().match('#(.*)')){ elementText.push($(selected).text().match('#(.*)')); } }); a=elementText.join();