javascript - Script to convert text inside <li> lines into search links -
i have several divs lis inside, want convert text within of lis belongs specific div id, example:
<div id="filtro_mod"> <ul> <li><strong>hp designjet 100 printer series</strong> <ul> <li>hp designjet 100 printer - c7796a</li> <li>hp designjet 100 printer - c7796ar</li> </ul> </li> <li><strong>hp designjet 100 plus printer series</strong> <ul> <li>hp designjet 100 plus printer - c7796c</li> <li>hp designjet 100 plus printer - c7796cr</li> </ul> </li> </ul> </div>
so pretend convert this:
<li>hp designjet 100 printer - c7796a</li>
into this:
<li><a href="http://mywebsite.com/pesquisa?controller=search&orderby=position&orderway=desc&search_query=hp%20designjet%20100%20printer%20-%20c7796a+&submit_search=">hp designjet 100 printer - c7796a</a></li>
however in lines there strong within li others lis. example:
<ul> <li><strong>hp designjet 100 printer series</strong> <ul> <li>hp designjet 100 printer - c7796a</li> <li>hp designjet 100 printer - c7796ar</li> </ul> </li> </ul>
i think possible script convert plain urls text links this:
how replace plain urls links?
$('#filtro_mod li li').each(function(){ var html = $(this).html(); $(this).html('<a href="theurl.com?desc=' + html + '">' + html + '</a>'); });
javascript jquery html regex anchor
No comments:
Post a Comment