简体   繁体   中英

Change HTML Tags from fetched data with JavaScript?

I am trying to change HTML tags from Data I'm fetching with an API. I am at a point that the text from the API is being displayed on the page but this text includes header tags that I would like to make a different header. For example to an . I have tried to use: function(){ $('p').replaceWith('divs rule!'); }); but this applies to the whole page. Is this possible?

You can replace the data at retrieval time:

.done(function (html) {
    $(html).find("p").replaceWith("divs rule!");
});

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