jQuery addClass example
Change class name on click in jQuery
HTML
<div>POST Title</div>
<div id="post-title"> </div>
<div>POST Content</div>
<div id="post-content"></div>
<div>POST Link</div>
<div id="post-link"></div>
CSS
body {
background: white;
font-family: Helvetica;
}
#post-title {
border: 1px solid green;
padding: 5px;
}
#post-content {
border: 1px solid blue;
padding: 5px;
}
#post-link {
border: 1px solid red;
padding: 5px;
}
JavaScript
$( document ).ready(function() {
$.ajax({
type: 'GET',
url: "https://wptavern.com/wp-json/wp/v2/posts/79564",
dataType: 'json',
success: function(json)
{
$('#post-title').html(json.title.rendered);
$('#post-content').html(json.content.rendered);
$('#post-link').html(json.link);
}
});
});