사용자가 선택한 언어를 보여주기 위해 텍스트를 변경할 수있는 스크립트 작업 중입니다.
사실, 페이지로드시 기본으로 ita 언어를 사용하고 있습니다. 그것은 모든 Divs에서 작동하지만 div는 제외합니다. 나는 이유를 이해할 수 없다. 예외를 발생시키지 않는다. 이건 내 스크립트입니다 : 나는 innested 사업부에 "대체"다음에 "경고"textToEdit 변수를 시도
var pattEng1 = /\[lang='eng']/g;
var pattEng2 = /\[.{1}lang='eng']/g;
var pattIta1 = /\[lang='ita']/g;
var pattIta2 = /\[.{1}lang='ita']/g;
var langs = ["ita","eng"];
var texts = new Array();
var i = 0, j;
var textToEdit, startPosEng, endPosEng;
$("div").each(function(){
texts.push($(this).html());
textToEdit = texts[i];
startPosEng = textToEdit.search(pattEng1) + 12;
endPosEng = textToEdit.search(pattEng2) - startPosEng;
textToEdit = textToEdit.replace(textToEdit.substr(startPosEng,endPosEng),"");
try {
$(this).html(textToEdit);
}
catch(err) {
$("#demo").html(err.message);
}
j = 0;
while(j < langs.length) {
textToEdit = $(this).html();
textToEdit = textToEdit.replace("[lang='"+langs[j]+"']", "");
textToEdit = textToEdit.replace("[\/lang='"+langs[j]+"']", "")
$(this).html(textToEdit);
j++;
}
i++;
});
, 그리고 그것이 대체 무슨 대체 작동하지만,이 $에 넣어하지 않습니다 (this) .html (textToEdit).
정말 고마워요. 여기 내 HTML 코드 :
<div>
[lang='eng']
CHAPTER ONE - 01<br>
THE BOY WHO LIVED<br>
Mr. and Mrs. Dursley, of number four, Privet Drive, were proud to say
that they were perfectly normal, thank you very much. They were the last
people you'd expect to be involved in anything strange or mysterious,
because they just didn't hold with such nonsense.<br>
Mr. Dursley was the director of a firm called Grunnings, which made
drills. He was a big, beefy man with hardly any neck, although he did
have a very large mustache. Mrs. Dursley was thin and blonde and had
nearly twice the usual amount of neck, which came in very useful as she
spent so much of her time craning over garden fences, spying on the
neighbors. The Dursleys had a small son called Dudley and in their
opinion there was no finer boy anywhere.<br>
The Dursleys had everything they wanted, but they also had a secret, and
their greatest fear was that somebody would discover it. They didn't
think they could bear it if anyone found out about the Potters. Mrs.
Potter was Mrs. Dursley's sister, but they hadn't met for several years;
in fact, Mrs. Dursley pretended she didn't have a sister, because her
sister and her good-for-nothing husband were as unDursleyish as it was
possible to be. The Dursleys shuddered to think what the neighbors would
say if the Potters arrived in the street. The Dursleys knew that the
Potters had a small son, too, but they had never even seen him. This boy
was another good reason for keeping the Potters away; they didn't want
Dudley mixing with a child like that.[/lang='eng']
[lang='ita']
CAPITOLO UNO - 01<br>
IL RAGAZZO SOPRAVVISSUTO<br>
Mr e Mrs Dursley, di Privet Drive numero 4, erano orgogliosi di poter affermare che erano
perfettamente normali e grazie tante. Erano le ultime persone al mondo da cui aspettarsi che
avessero a che fare con cose strane o misteriose, perché sciocchezze del genere proprio non le approvavano.<br>
Mr Dursley era direttore di una ditta di nome Grunnings, che fabbricava trapani. Era un uomo
corpulento, nerboruto, quasi senza collo e con un grosso paio di baffi. Mrs Dursley era magra,
bionda e con un collo quasi due volte più lungo del normale, il che le tornava assai utile, dato che
passava gran parte del tempo ad allungarlo oltre la siepe del giardino per spiare i vicini.
I Dursley avevano un figlioletto di nome Dudley e secondo loro non esisteva al mondo un bambino più bello.[/lang='ita']
<div>
[lang='eng']
CHAPTER ONE - 01b<br>
THE BOY WHO LIVED<br>
Mr. and Mrs. Dursley, of number four, Privet Drive, were proud to say
that they were perfectly normal, thank you very much. They were the last
people you'd expect to be involved in anything strange or mysterious,
because they just didn't hold with such nonsense.<br>
Mr. Dursley was the director of a firm called Grunnings, which made
drills. He was a big, beefy man with hardly any neck, although he did
have a very large mustache. Mrs. Dursley was thin and blonde and had
nearly twice the usual amount of neck, which came in very useful as she
spent so much of her time craning over garden fences, spying on the
neighbors. The Dursleys had a small son called Dudley and in their
opinion there was no finer boy anywhere.<br>
The Dursleys had everything they wanted, but they also had a secret, and
their greatest fear was that somebody would discover it. They didn't
think they could bear it if anyone found out about the Potters. Mrs.
Potter was Mrs. Dursley's sister, but they hadn't met for several years;
in fact, Mrs. Dursley pretended she didn't have a sister, because her
sister and her good-for-nothing husband were as unDursleyish as it was
possible to be. The Dursleys shuddered to think what the neighbors would
say if the Potters arrived in the street. The Dursleys knew that the
Potters had a small son, too, but they had never even seen him. This boy
was another good reason for keeping the Potters away; they didn't want
Dudley mixing with a child like that.[/lang='eng']
[lang='ita']
CAPITOLO UNO - 01b<br>
IL RAGAZZO SOPRAVVISSUTO<br>
Mr e Mrs Dursley, di Privet Drive numero 4, erano orgogliosi di poter affermare che erano
perfettamente normali e grazie tante. Erano le ultime persone al mondo da cui aspettarsi che
avessero a che fare con cose strane o misteriose, perché sciocchezze del genere proprio non le approvavano.<br>
Mr Dursley era direttore di una ditta di nome Grunnings, che fabbricava trapani. Era un uomo
corpulento, nerboruto, quasi senza collo e con un grosso paio di baffi. Mrs Dursley era magra,
bionda e con un collo quasi due volte più lungo del normale, il che le tornava assai utile, dato che
passava gran parte del tempo ad allungarlo oltre la siepe del giardino per spiare i vicini.
I Dursley avevano un figlioletto di nome Dudley e secondo loro non esisteva al mondo un bambino più bello.[/lang='ita']
</div>
</div>
<br><br><br><br>
<div>
[lang='eng']
CHAPTER ONE - 03<br>
THE BOY WHO LIVED<br>
Mr. and Mrs. Dursley, of number four, Privet Drive, were proud to say
that they were perfectly normal, thank you very much. They were the last
people you'd expect to be involved in anything strange or mysterious,
because they just didn't hold with such nonsense.<br>
Mr. Dursley was the director of a firm called Grunnings, which made
drills. He was a big, beefy man with hardly any neck, although he did
have a very large mustache. Mrs. Dursley was thin and blonde and had
nearly twice the usual amount of neck, which came in very useful as she
spent so much of her time craning over garden fences, spying on the
neighbors. The Dursleys had a small son called Dudley and in their
opinion there was no finer boy anywhere.<br>
The Dursleys had everything they wanted, but they also had a secret, and
their greatest fear was that somebody would discover it. They didn't
think they could bear it if anyone found out about the Potters. Mrs.
Potter was Mrs. Dursley's sister, but they hadn't met for several years;
in fact, Mrs. Dursley pretended she didn't have a sister, because her
sister and her good-for-nothing husband were as unDursleyish as it was
possible to be. The Dursleys shuddered to think what the neighbors would
say if the Potters arrived in the street. The Dursleys knew that the
Potters had a small son, too, but they had never even seen him. This boy
was another good reason for keeping the Potters away; they didn't want
Dudley mixing with a child like that.[/lang='eng']
[lang='ita']
CAPITOLO UNO - 03<br>
IL RAGAZZO SOPRAVVISSUTO<br>
Mr e Mrs Dursley, di Privet Drive numero 4, erano orgogliosi di poter affermare che erano
perfettamente normali e grazie tante. Erano le ultime persone al mondo da cui aspettarsi che
avessero a che fare con cose strane o misteriose, perché sciocchezze del genere proprio non le approvavano.<br>
Mr Dursley era direttore di una ditta di nome Grunnings, che fabbricava trapani. Era un uomo
corpulento, nerboruto, quasi senza collo e con un grosso paio di baffi. Mrs Dursley era magra,
bionda e con un collo quasi due volte più lungo del normale, il che le tornava assai utile, dato che
passava gran parte del tempo ad allungarlo oltre la siepe del giardino per spiare i vicini.
I Dursley avevano un figlioletto di nome Dudley e secondo loro non esisteva al mondo un bambino più bello.[/lang='ita']
</div>
<br><br><br><br>
<div>
[lang='eng']
CHAPTER ONE - 04<br>
THE BOY WHO LIVED<br>
Mr. and Mrs. Dursley, of number four, Privet Drive, were proud to say
that they were perfectly normal, thank you very much. They were the last
people you'd expect to be involved in anything strange or mysterious,
because they just didn't hold with such nonsense.<br>
Mr. Dursley was the director of a firm called Grunnings, which made
drills. He was a big, beefy man with hardly any neck, although he did
have a very large mustache. Mrs. Dursley was thin and blonde and had
nearly twice the usual amount of neck, which came in very useful as she
spent so much of her time craning over garden fences, spying on the
neighbors. The Dursleys had a small son called Dudley and in their
opinion there was no finer boy anywhere.<br>
The Dursleys had everything they wanted, but they also had a secret, and
their greatest fear was that somebody would discover it. They didn't
think they could bear it if anyone found out about the Potters. Mrs.
Potter was Mrs. Dursley's sister, but they hadn't met for several years;
in fact, Mrs. Dursley pretended she didn't have a sister, because her
sister and her good-for-nothing husband were as unDursleyish as it was
possible to be. The Dursleys shuddered to think what the neighbors would
say if the Potters arrived in the street. The Dursleys knew that the
Potters had a small son, too, but they had never even seen him. This boy
was another good reason for keeping the Potters away; they didn't want
Dudley mixing with a child like that.[/lang='eng']
[lang='ita']
CAPITOLO UNO - 04<br>
IL RAGAZZO SOPRAVVISSUTO<br>
Mr e Mrs Dursley, di Privet Drive numero 4, erano orgogliosi di poter affermare che erano
perfettamente normali e grazie tante. Erano le ultime persone al mondo da cui aspettarsi che
avessero a che fare con cose strane o misteriose, perché sciocchezze del genere proprio non le approvavano.<br>
Mr Dursley era direttore di una ditta di nome Grunnings, che fabbricava trapani. Era un uomo
corpulento, nerboruto, quasi senza collo e con un grosso paio di baffi. Mrs Dursley era magra,
bionda e con un collo quasi due volte più lungo del normale, il che le tornava assai utile, dato che
passava gran parte del tempo ad allungarlo oltre la siepe del giardino per spiare i vicini.
I Dursley avevano un figlioletto di nome Dudley e secondo loro non esisteva al mondo un bambino più bello.[/lang='ita']
</div>
<br><br><br><br>
<div>
[lang='eng']
CHAPTER ONE - 05<br>
THE BOY WHO LIVED<br>
Mr. and Mrs. Dursley, of number four, Privet Drive, were proud to say
that they were perfectly normal, thank you very much. They were the last
people you'd expect to be involved in anything strange or mysterious,
because they just didn't hold with such nonsense.<br>
Mr. Dursley was the director of a firm called Grunnings, which made
drills. He was a big, beefy man with hardly any neck, although he did
have a very large mustache. Mrs. Dursley was thin and blonde and had
nearly twice the usual amount of neck, which came in very useful as she
spent so much of her time craning over garden fences, spying on the
neighbors. The Dursleys had a small son called Dudley and in their
opinion there was no finer boy anywhere.<br>
The Dursleys had everything they wanted, but they also had a secret, and
their greatest fear was that somebody would discover it. They didn't
think they could bear it if anyone found out about the Potters. Mrs.
Potter was Mrs. Dursley's sister, but they hadn't met for several years;
in fact, Mrs. Dursley pretended she didn't have a sister, because her
sister and her good-for-nothing husband were as unDursleyish as it was
possible to be. The Dursleys shuddered to think what the neighbors would
say if the Potters arrived in the street. The Dursleys knew that the
Potters had a small son, too, but they had never even seen him. This boy
was another good reason for keeping the Potters away; they didn't want
Dudley mixing with a child like that.[/lang='eng']
[lang='ita']
CAPITOLO UNO - 05<br>
IL RAGAZZO SOPRAVVISSUTO<br>
Mr e Mrs Dursley, di Privet Drive numero 4, erano orgogliosi di poter affermare che erano
perfettamente normali e grazie tante. Erano le ultime persone al mondo da cui aspettarsi che
avessero a che fare con cose strane o misteriose, perché sciocchezze del genere proprio non le approvavano.<br>
Mr Dursley era direttore di una ditta di nome Grunnings, che fabbricava trapani. Era un uomo
corpulento, nerboruto, quasi senza collo e con un grosso paio di baffi. Mrs Dursley era magra,
bionda e con un collo quasi due volte più lungo del normale, il che le tornava assai utile, dato che
passava gran parte del tempo ad allungarlo oltre la siepe del giardino per spiare i vicini.
I Dursley avevano un figlioletto di nome Dudley e secondo loro non esisteva al mondo un bambino più bello.[/lang='ita']
</div>
<br><br><br><br>
<div>
CHAPTER ONE - 06<br>
THE BOY WHO LIVED<br>
Mr. and Mrs. Dursley, of number four, Privet Drive, were proud to say
that they were perfectly normal, thank you very much. They were the last
people you'd expect to be involved in anything strange or mysterious,
because they just didn't hold with such nonsense.<br>
Mr. Dursley was the director of a firm called Grunnings, which made
drills. He was a big, beefy man with hardly any neck, although he did
have a very large mustache. Mrs. Dursley was thin and blonde and had
nearly twice the usual amount of neck, which came in very useful as she
spent so much of her time craning over garden fences, spying on the
neighbors. The Dursleys had a small son called Dudley and in their
opinion there was no finer boy anywhere.<br>
The Dursleys had everything they wanted, but they also had a secret, and
their greatest fear was that somebody would discover it. They didn't
think they could bear it if anyone found out about the Potters. Mrs.
Potter was Mrs. Dursley's sister, but they hadn't met for several years;
in fact, Mrs. Dursley pretended she didn't have a sister, because her
sister and her good-for-nothing husband were as unDursleyish as it was
possible to be. The Dursleys shuddered to think what the neighbors would
say if the Potters arrived in the street. The Dursleys knew that the
Potters had a small son, too, but they had never even seen him. This boy
was another good reason for keeping the Potters away; they didn't want
Dudley mixing with a child like that.<br>
CAPITOLO UNO - 06<br>
IL RAGAZZO SOPRAVVISSUTO<br>
Mr e Mrs Dursley, di Privet Drive numero 4, erano orgogliosi di poter affermare che erano
perfettamente normali e grazie tante. Erano le ultime persone al mondo da cui aspettarsi che
avessero a che fare con cose strane o misteriose, perché sciocchezze del genere proprio non le approvavano.<br>
Mr Dursley era direttore di una ditta di nome Grunnings, che fabbricava trapani. Era un uomo
corpulento, nerboruto, quasi senza collo e con un grosso paio di baffi. Mrs Dursley era magra,
bionda e con un collo quasi due volte più lungo del normale, il che le tornava assai utile, dato che
passava gran parte del tempo ad allungarlo oltre la siepe del giardino per spiare i vicini.
I Dursley avevano un figlioletto di nome Dudley e secondo loro non esisteva al mondo un bambino più bello.
</div>
불행하게도, 그것은 동일합니다 ... – ProtoTyPus
는 [당신은습니다 넣을 수 예.] (http://stackoverflow.com/help/mcve) – Jai
예제가 아직 없습니다! 당신은 복사 할 수 있습니다 - 내 HTML 코드와 js 붙여 넣기 : – ProtoTyPus