seblondres Posted October 26, 2014 Share Posted October 26, 2014 (edited) Hi, I'm trying to display the following results inline. For the moment the outcome is as follow: Title Description and I'd like to remove the space between the two so it looks like the below with also the title underline: Title Description Here is the code: $(function() {$(document).ready(function(){$.getJSON("https://partner-int-api.groupon.com/deals.json?country_code=UK&tsToken=IE_AFF_0_201236_212556_0&filters=category:food-and-drink&offset=0&limit=50&callback=?",function(data){$.each(data.deals, function(i,data){var div_data ="<div><a href='"+data.dealUrl+"'>"+data.title+"</a><p>"+data.highlightsHtml+"</p></div>";$(div_data).appendTo("#showdata");});});return false;});}); Thanks for your help, Seb Edited October 26, 2014 by seb_london Link to comment Share on other sites More sharing options...
niche Posted October 26, 2014 Share Posted October 26, 2014 http://stackoverflow.com/questions/6246273/how-to-change-the-display-of-a-div-using-javascript Link to comment Share on other sites More sharing options...
seblondres Posted November 5, 2014 Author Share Posted November 5, 2014 Thanks for your feedback and the link. I have added: document.getElementById('showdata').style.display = 'block'; to $(function() {$(document).ready(function(){$.getJSON("https://partner-int-api.groupon.com/deals.json?country_code=UK&tsToken=IE_AFF_0_201236_212556_0&filters=category:food-and-drink&offset=0&limit=50&callback=?",function(data){$.each(data.deals, function(i,data){var div_data ="<div><a href='"+data.dealUrl+"'>"+data.title+"</a><p>"+data.highlightsHtml+"</p></div>";$(div_data).appendTo("#showdata");document.getElementById('showdata').style.display = 'block';});});return false;});}); but I still have a space between the tittle and the description Link to comment Share on other sites More sharing options...
dsonesuk Posted November 5, 2014 Share Posted November 5, 2014 Its probably do to the margins set to paragraph element, give the div a classname var div_data ="<div class="whatever"><a href='"+data.dealUrl+"'>"+data.title+"</a><p>"+data.highlightsHtml+"</p></div>"; then use css to adjust paragraph margin within that element .whatever p{ margin-top: 0;} Link to comment Share on other sites More sharing options...
dsonesuk Posted November 5, 2014 Share Posted November 5, 2014 Also this $(function() is the same as $(document).ready(function() Use one or the other, both are not required. Link to comment Share on other sites More sharing options...
seblondres Posted November 6, 2014 Author Share Posted November 6, 2014 Thanks but when I add the class then the groupon feed don't appear any more: My Css: .desc p { margin-top: 0;} JS code: <script>$(function() {$(document).ready(function(){$.getJSON("https://partner-int-api.groupon.com/deals.json?country_code=UK&tsToken=IE_AFF_0_201236_212556_0&filters=category:food-and-drink&offset=0&limit=10&callback=?",function(data){$.each(data.deals, function(i,data){var div_data ="<div class="desc"><a href='"+data.dealUrl+"'>"+data.title+"</a><p>"+data.highlightsHtml+"</p></div>";$(div_data).appendTo("#showdata");});});return false;});});</script> Link to comment Share on other sites More sharing options...
dsonesuk Posted November 6, 2014 Share Posted November 6, 2014 (edited) Sorry!, i'm so used to using single quotes to enclose text string like var div_data ='<div class="desc"><a href="'+data.dealUrl+'">'+data.title+'</a><p>'+data.highlightsHtml+'</p></div>'; which means i can enter class="desc" as you normally would, without affecting the code. with yours it should be var div_data = "<div class='desc'><a href='"+data.dealUrl+"'>"+data.title+"</a><p>"+data.highlightsHtml+"</p></div>"; Edited November 6, 2014 by dsonesuk Link to comment Share on other sites More sharing options...
seblondres Posted November 6, 2014 Author Share Posted November 6, 2014 ok great it works, but I had to change the css to: .desc a + * { margin-top:-18px;} Thanks a lot for your help! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now