简体   繁体   中英

How to encode the url in Javascript

How to encode the url in this case: http://jsfiddle.net/spem/c89r1vu1/4/

<script type='text/javascript'>
$('#pnumbers li strong').each(function () {
    var html = $(this).html();
    $(this).html('<a href="http://example.com/search_query=' + html + '">' + html + '</a>');
});
</script>
<div id="pnumbers" class="rte">
    <ul>
        <li><strong>Isto é um teste</strong>

        </li>
        <li><strong>HP Q1292-67026</strong>

        </li>
    </ul>
</div>

据我了解,您在问有关encodeURIComponent()函数的问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM