0
<div id="one">
    <label for="number">Number</label>
    <div id="two">
        <input id="number" type="text" name="number">
    </div>   
</div>

This show me:

  1. Number
  2. [input]

How can I make:

  1. Number [input]

How can I modify this with jQuery? (not modify html)

LIVE: http://jsfiddle.net/UBx6p/

3
  • 1
    Modify CSS -- jsfiddle.net/Jayendra/UBx6p/1 Commented Oct 3, 2011 at 10:52
  • 1
    Modifying the CSS wold be the most straightforward thing to do. Do you have access to it? Commented Oct 3, 2011 at 10:52
  • Why would you want to modify it with jQuery and not HTML? Commented Oct 3, 2011 at 10:53

4 Answers 4

2

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>
Sign up to request clarification or add additional context in comments.

Comments

1

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/

Comments

1

Can you use CSS rather than javascript?

#two {
    display:inline-block;
}

Comments

1

If you want it only in JS. Then as suggested use something like this

document.getElementById('two').style.display = 'inline'; 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.