I'm trying to replace all uses of @[Insert_handle_here] to a link to the respective twitter account.
This is my current code.
function replaceAts(){
for (var i=0; i<list.length;i++){
list[i].text=list[i].text.replace(/@(\w+)/g, '<a href="https://twitter.com/$1" target="_blank">%$1</a>')
}
}
I'm not really sure how it works, as I pretty much directly coped from another Stack Overflow post, but its showing up really weird on the actual web page.
For example, the text from my friends account
If you want these foams Ima give you the chrome @WillThaRapper
Shows up as If you want these foams Ima give you the chrome <a href="https://twitter.com/WillThaRapper" target="_blank">%WillThaRapper</a>
Which is not ideal.
Any advice?
Aucun commentaire:
Enregistrer un commentaire