Javascript:用html中的行分隔json对象
所以我在我的html页面中加载了一些json对象(参见图),但我想用一些类似于图中蓝线的线来分隔它们。有什么办法吗?我的形象: 我的js代码Javascript:用html中的行分隔json对象,javascript,html,json,line,Javascript,Html,Json,Line,所以我在我的html页面中加载了一些json对象(参见图),但我想用一些类似于图中蓝线的线来分隔它们。有什么办法吗?我的形象: 我的js代码 $.getJSON("http://newsapi.org/v2/top-headlines?country=gr&category=health&apiKey=APIKEY", function(data){ $.each(data.articles,function(index,value){ console.lo
$.getJSON("http://newsapi.org/v2/top-headlines?country=gr&category=health&apiKey=APIKEY", function(data){
$.each(data.articles,function(index,value){
console.log(data);
var author = value.author;
if (author==null){
author="No author";
}
var title = value.title;
var description = value.description;
if(description==null){
description ="No description";
}
var url = value.url;
$('.output').append('<p class="author">'+author+'</p><h2 class ="title">'+title+'</h2><p
class="description">'+description+'</p><a class="url" href="'+url+'" >Read Article</a>'); //here i append the data to my page
});
});
$.getJSON(“http://newsapi.org/v2/top-headlines?country=gr&category=health&apiKey=APIKEY,函数(数据){
$.each(数据、文章、函数(索引、值){
控制台日志(数据);
var author=value.author;
if(author==null){
author=“无作者”;
}
var title=value.title;
var description=value.description;
if(description==null){
description=“无描述”;
}
var url=value.url;
$('.output').append('“+description+”
”;//这里我将数据附加到我的页面中
});
});
'+title+'
我希望这能奏效
hr标签将绘制水平线
如果线条没有变为蓝色,请尝试使用“背景色”属性替换颜色
我希望这能奏效
hr标签将绘制水平线
如果线条没有变为蓝色,请尝试使用“背景色”属性替换颜色 尝试使用@Duad和@Imarqs建议的
hr
标记。如果您不想在最后一项下使用蓝线,请尝试此项
let-arr=[
{
作者:“A”,
标题:“TitleA”,
网址:“google.com”
},
{
作者:“B”,
标题:“标题”,
网址:“youtube.com”
},
{
作者:“C”,
标题:“标题”,
网址:“facebook.com”
}
];
$。每个(arr,(索引,值)=>{
让include=(索引!=arr.length-1);
$('.output').append(`
:“}`)
});代码>
hr{
背景色:天蓝色;
填充:1px;
}
尝试使用@Duad和@Imarqs建议的hr
标记。如果您不想在最后一项下使用蓝线,请尝试此项
let-arr=[
{
作者:“A”,
标题:“TitleA”,
网址:“google.com”
},
{
作者:“B”,
标题:“标题”,
网址:“youtube.com”
},
{
作者:“C”,
标题:“标题”,
网址:“facebook.com”
}
];
$。每个(arr,(索引,值)=>{
让include=(索引!=arr.length-1);
$('.output').append(`
:“}`)
});代码>
hr{
背景色:天蓝色;
填充:1px;
}
适当使用
:适当使用
:
$('.output').append('<p class="author">'+author+'</p><h2 class ="title">'+title+'</h2><p
class="description">'+description+'</p><a class="url" href="'+url+'" >Read Article</a><class='blue-color' hr>'); //here i append the data to my page
.blue-color {
color: blue;
}
${value.title}${include?”
${value.title}${include?”