简体   繁体   中英

Covert jQuery to javascript

This is my code please covert my jQuery into javascript. Convert in javascript

$(".wrapper td li>span").text(function () {
        return $(this).text().replace(".", ""); 
    });

Using querySelectorAll and textContent

 document.querySelectorAll('span').forEach(function(el) { el.textContent = el.textContent.replace(/\\./g, '') });
 <span>1. abc</span><br/> <span>2. def</span>

Finally I got a proper answer to convert jQuery to JavaScript with and issues on enterprise mode of internet explorer

var spans=document.body.querySelectorAll('.wrapper td li>span')
for (i = 0; i < spans.length; i++) {
spans[i].innerText = spans[i].innerText.replace(/\./g, '')
}

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