0

I would like to remove a space between two divs but I don't want to hide it moving the margins, I want to DELETE it! This is my code:

<html>
<head>
<style>
div{
    display:inline;zoom:1;
    margin:0px;outline:none;
}

</style>
</head>
<body>


<div style="margin-right:0;" id="test">content</div>
<div>
people
</div>

<script>
var n = 11;
document.getElementById('test').innerHTML = n;
function s(){
n=n+1;
document.getElementById('test').innerHTML = n;
}
</script>
</div>


<br><br><br>
<button onclick="s()">Add one</button>

<br><br><br>

</body>
</html>

I would like it to be "11people" instead of "11 people". Thanks!

  • In modern browsers: `document.getElementById("test").nextSibling.remove()` –  Mar 28 '16 at 18:31
  • Refer to: http://stackoverflow.com/questions/12237379/stick-two-divs-to-another – Rafael Quintanilha Mar 28 '16 at 18:31
  • In older browsers: `var t = document.getElementById("test"); t.parentNode.removeChild(t.nextSibling)` –  Mar 28 '16 at 18:31
  • @squint Arranging those div elements in a single line in html wouldn't fix that issue? – Rajaprabhu Aravindasamy Mar 28 '16 at 18:32
  • 1
    @RajaprabhuAravindasamy: It would but I imagine they don't have control over the HTML source, otherwise I'd think they'd simply do that. If they do control the source, then that would be the clear solution to use. –  Mar 28 '16 at 18:33
  • @squint I tried to put both the codes in the "script> tags but it doesn't work – Andrea Paternoster Mar 28 '16 at 18:37
  • Oh, you also have a line break before `people`. If you control the HTML source, then clearly you just need to remove the spaces you're putting in the HTML. If you can't then you'll also need to select the `.nextElementSibling` after the `test` element, and `.trim()` its `.textContent`. –  Mar 28 '16 at 18:43

0 Answers0