I'm using Google Custom Search API to fetch and publish JSON callback results. I've been tinkering around with the json results callback variables as per Google recommend documentation here:
Wondering how I can use either Javascript variable or other to add CSS/styling to HTML elements that I'm using to produce styled titles, desctiptions & links for Google custom search results on the page?
Here's the code I'm using now:
<div>
<script>
function hndlr(response) {
for (var i = 0; i < response.items.length; i++) {
var item = response.items[i];
// in production code, item.htmlTitle should have the HTML entities escaped.
document.getElementById("content").innerHTML += "<span>" + item.title;
document.getElementById("content").innerHTML += "<p>" + item.snippet +"<u><a href='"+item.link+"'>(continue reading)</a>";
}
}
</script>
<script src="https://www.googleapis.com/customsearch/v1?key=API_KEY&cx=GOOGLE_CUSTOM_SEARCH_ID&q=MY+QUERY+WORDSS&callback=hndlr">
</script>
</div>
How should I add styling to the HTML elements in my code for span, p, etc?
Also, is there a more simple method to just fetch the top ten search results with HTML styling same as it appears Google.com search results page? This would be nice!
Thanks for your help!