[英]How to change the font attributes and position of JSON data?
I am newbie to web page designing. 我是网页设计的新手。 Well now i am working with JSON.
好吧,现在我正在使用JSON。 And yeah, I am doing my own project for a quote machine for freecodecamp.
是的,我正在为freecodecamp的报价机做自己的项目。 The thing is i am able to display JSON data to my
<div>
.But how do I edit the font attributes and position of the JSON data that is appearing. 问题是我可以在
<div>
上显示JSON数据。但是,如何编辑显示的JSON数据的字体属性和位置。 I also attaching the js script. 我还附加了js脚本。
$(document).ready(function(){
$(".btn").on('click',function(){
$.ajaxSetup ({cache:false});
$.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&callback=", function(data) {
$(".message").html(data[0].content + " — " + data[0].title);
});
});
});
try setting the css of the element after setting the content: 设置内容后,尝试设置元素的CSS:
$(".message").css({'font-family':'Arial', 'left':'19px'});
Or alternatively you could use a CSS class to achieve the same result: 或者,您也可以使用CSS类来达到相同的结果:
.message {
font-family: 'Arial'; //or whatever font you want
left: 19px; //or whatever positioning css changes need to be made.
}
The better way is using CSS to style the elements. 更好的方法是使用CSS设置元素的样式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.