简体   繁体   中英

convert quotation marks into HTML codes in large text

I am creating an application in HTML, CSS, Jquery Mobile, that will be having a big text. To get that text, I have to copy it from another resource and in my text editor they look fine. (They are like "This is double quotes",'This is single quotes'). But in the browser the quotation marks become something like ’ and because the text is so big, I can't go changing each mark with ".

So how can I convert those quotation marks in such big text into HTML Codes that will look how they are supposed to look in the browser?

First, find all quotations marks that can appear in your text. Than, foreach quotation marks, for example single quote ', replace it with \\':

var initialText = document.getElementById("text").innerHTML; 
var finalText = str.replace(initialText, "\'");
finalText = str.replace(finalText, '\"');

Finally use variable "finalText". Notice that first you replace variable "initialText", after first iteration you replace variable "finalText"

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