2016-12-09 7 views
0

私は質問結果への回答を生成し、htmlに配置するページに簡単なJSクイズを持っています。回答のカップルでは、​​それが好きな人は 'ここをクリックして詳細を聞いてください'と言っています。どのようにHTMLに配置されているJS文字列へのリンクを追加するのですか?JSドリブンクイズの回答にリンクを追加するにはどうすればよいですか?

このついて行くにはどのように本当にわからないJSに非常に新しいイム...

これはで呼び出さなっているJSです:

{ // Question 
 
    "q": "<h4>Is it recommended to use one vial of BOTOX<sup>&reg;</sup> on more than one patient?</h4>", 
 
    "a": [ 
 
    {"option": "TRUE",  "correct": false}, 
 
    {"option": "FALSE",  "correct": true} 
 
    ], 
 
    "correct": "<p><span>CORRECT!</span> As the diluents in BOTOX<sup>®</sup> do not contain a preservative it is not recommended to use on more than one patient.2 If you would like to refer to this information again, it can be found via the link below.</p>", 
 
    "incorrect": "<p><span>INCORRECT.</span> As the diluents in BOTOX<sup>®</sup> do not contain a preservative it is not recommended to use on more than one patient.<sup>2</sup> If you would like to refer to this information again, it can be found via the link below.</p><p>***here is where I would like the link to be***</p>" 
 
},

答えて

1

することができますlink()メソッドを使用してJavaScript内のリンクを含める:

var str = "This is the text that will show up"; 
var textToPrint = str.link("http://samplewebsite.com"); 

textToPrintを印刷すると、This is the text that will show upのように印刷されます。

+0

どのように/それをスクリプトに追加しますか?そして、html文字列でvarをどのように呼び出すのですか? – DaveP19

+0

既存のコードブロックにURLを追加することができます。私はあなたが現在のJavascriptを使って何をしようとしているのか本当に分かりません。コードをもっと投稿して、HTMLをどのように操作しているのか考えてください。 –

+0

ああ私はリンクを追加するコードを書くにはどうすればいいですか... 上記のjsコードで私はこれを持っています -

***ここに私がリンクを希望したい場所です

- 私はリンクを書く必要があるthats。だから私はどのようにそのスペースでリンクvarと呼ぶのですか? – DaveP19

関連する問題