2016-09-21 9 views

答えて

0

$(document).ready(function(){ 
 
    var question = "this is ' new ' question ' from my side"; 
 
    var answer = "this is ' new ' answer ' from my side"; 
 
    showContent(question, answer); 
 
}); 
 

 
function showContent(question, answer) { 
 
    document.getElementById("question").innerHTML = ReplaceString(question,"'","\\'"); 
 
    document.getElementById("answer").innerHTML = ReplaceString(answer, "'", "\\'"); 
 
} 
 

 
function ReplaceString(message, oldString, newString) {   
 
    return message.split(oldString).join(newString); 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div id="question"></div> 
 
<div id="answer"></div>

関連する問題