Reputation: 35
<div id="one">
<label for="number">Number</label>
<div id="two">
<input id="number" type="text" name="number">
</div>
</div>
This show me:
How can I make:
How can I modify this with jQuery? (not modify html)
LIVE: http://jsfiddle.net/UBx6p/
Upvotes: 0
Views: 210
Reputation: 601
Well, you really should change the HTML as stated above by Xavi.
If that is out of the question, you can perform the HTML changes via jQuery:
$('#one label').css('float', 'left');
$('#one #two').css('float', 'left');
$('#one #two').css('margin-left', '5px');
$('#one').append('<div style="clear:both"></div>');
put it here : http://jsfiddle.net/UBx6p/8/
Upvotes: 1
Reputation: 2861
If you want it only in JS. Then as suggested use something like this
document.getElementById('two').style.display = 'inline';
Upvotes: 1
Reputation: 27880
Use a <span>
instead of a <div>
.
<div id="one">
<label for="number">Number</label>
<span id="two">
<input id="number" type="text" name="number">
</span>
</div>
Upvotes: 2
Reputation: 11617
Can you use CSS rather than javascript?
#two {
display:inline-block;
}
Upvotes: 1