拒否とその仕組みを理解するのが難しいのですが、ウェブサイトの基本的な辞書/用語集を作成しようとしていますが、すでに多くの時間を費やしています。
そこに私のコード:
// MY MULTIPLE ARRAY
var myDictionnary = new Object();
myDictionnary.myDefinition = new Array();
myDictionnary.myDefinition.push({'term':"*1", 'definition':"My description here"});
myDictionnary.myDefinition.push({'term':"word", 'definition':"My description here"});
myDictionnary.myDefinition.push({'term':"my dog doesn't move", 'definition':"My description here"});
// MY FUNCTION
$.each(myDictionnary.myDefinition, function(){
var myContent = $('#content_right').html();
var myTerm = this.term;
var myRegTerm = new RegExp(myTerm,'g');
$('#content_right').html(myContent.replace(myRegTerm,'<span class="tooltip" title="'+this.definition+'"> *'+this.term+'</span>'));
});
配列を作成し、結果ごとに div#content_right で同じコンテンツを検索し、タイトルとツールチップを含むスパンに置き換えます。以前に試したことと混同しないように、正規表現を空にしました。
私の配列「用語」では、私が調査するテキストの種類を確認できます。「単語」などの通常のテキストを検索する場合に機能します。
しかし、「asterix」のような正規表現についてはバグです。それを過去にする方法を見つけたとき、彼はそれをテキストに追加します。「asterix」を通常の文字のように解釈する方法をいろいろ試しましたが、うまくいきません。
そこに私が欲しいもの:私の変数「myTerm」内のテキストが何であれ、変数を文字通り解釈します。これは可能ですか?そうでない場合、どのような解決策を使用する必要がありますか。
前もって感謝します、PS私の下手な英語で申し訳ありません...(私はフランス人です)アレックス