JSON :
{"data": {
"heading": "Module 2: Discussion Boards 1",
"description": "Students were asked to post to the Discussion board the responses they gathered from interviewing an experienced online instructor.\n Students were then asked to read the posts and offer feedback to their colleagues.",
"tabs": {
"tabItem": [
{
"value": "Edgar and Amy Conflict"
},
{
"value": "Oliver's Document"
},
{
"value": "Two Professors?"
}
]
}
}
}
자바 스크립트 :
var actual_JSON = JSON.parse(response);
document.getElementById("heading").innerHTML = actual_JSON.data.heading;
document.getElementById("description").innerHTML = actual_JSON.data.description;
결과
새 줄 ( \n
)이 작동하지 않습니다. 나는 시도 \\n
했지만 소용이 없었다.
제가 시도했을 때 var actual_JSON = JSON.strigify(response);
을 console.log에 내가 대체 할 경우 나는 새로운 라인을 얻을 수 \n
와 <br>
JSON에서하지만 그렇게 코드 나누기의 나머지 아래 개체로 작업을하지 않습니다.
나는 이와 관련하여 많은 게시물을 보았고 제시된 솔루션을 시도했지만 무언가가 누락되었습니다.
도움을 주셔서 감사합니다!
새 줄은 HTML 요소에 있기 때문에 효과적이지 않습니다.
<p> Hello this new line will
not work </p>
한 줄에 "Hello this new line will not work"가 표시됩니다.
그러나
<p> Hello this new line will <br />
work </p>
두 줄에 "Hello this new line will work"가 표시됩니다.
HTML 용 <br />
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다