[英]How to add HTML content in a json file
我有一個json文件,從中獲取HTML內容並在瀏覽器上顯示
"content": "Hello World <h1 class=\"page-title\">H1 Heading HTML tag</h1> <p>Para Tag</p>",
這在HTML內容很小時有效。
我應該如何處理大型HTML內容塊,如滑塊或手風琴。 是否可以調用文件而不是內容。
謝謝
嘗試使用html
, .load()
HTML
// e.g., "/path/to/html/"
<div id="first">Hello World 1 <h1 class="page-title">H1 Heading HTML tag</h1> <p>Para Tag</p></div>
<div class="second">Hello World 2 <h1 class="page-title">H1 Heading HTML tag</h1> <p>Para Tag</p></div>
<img src="image-1">
<img src="image-2">
JS
$("#container1").load("/path/to/html/ #first");
$("#container2").load("/path/to/html/ .second");
$("#container3").load("/path/to/html/ [src=image-1]");
$("#container4").load("/path/to/html/ img:eq(1)");
是的你可以。 像下面的代碼一樣加載div內容。
$.get('json.JSON',function(result){
//You will get the JSON data in result
$("#container").html(result.content);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.