tags:

views:

314

answers:

7

I want to generate an add and delete in the same row near to each other. (Not in a table)

$("<p class='addChoice cutsom_button'><a href='#' class='btn lbOn addchoice'><span class='button_image'><span class='background_16 user_reply'>Add</span></span></a></p>").appendTo(".fieldChoices");

$("<p class='deleteChoice cutsom_button'><a href='#' class='btn lbOn deletechoice'><span class='button_image'><span class='background_16 user_reply'>Delete</span></span></a></p>").appendTo(".fieldChoices");

How can I get both of them on the same row?

+6  A: 

I suspect you want a style like:

p.cutsom_button { display : inline; }
Noon Silk
that'll only work of the content happens to be short enough to fit both on the same line.
geowa4
geowa4: Indeed.
Noon Silk
But, looking at the example in the question, that might be the case. I think silky's answer comes closest to the requirement 'make two p tags show on the same row' +1
pavium
Using this in combination with 'white-space:nowrap;' will enable you to keep everything on one line when it starts wrapping.
Marien
+7  A: 

Don't use the <p> 'paragraph' tag.

pavium
Please consider writing a comment next time.
Georg
@gs: Why? I might have expanded on it a bit more, i.e. give an alternative or explain why he shouldn't use <p>, but it's a perfectly valid answer.
Graeme Perrow
Yes, I didn't think it was a very good answer as soon as I wrote it. And I commented that @silky's answer seemed to be more correct. But I appreciate the upvotes. I'll try not to squander them.
pavium
A: 

Make each float and specify a width of 50% or less.

geowa4
+1  A: 

The deleteChoice button should be marked with display:inline; in its css

http://www.tizag.com/cssT/display.php

mjd79
+2  A: 

The p tag is meant to represent a paragraph which is a block of text, thus the display mode is block. You could set the display to inline as others have suggested but this would still be semantically incorrect.

Judging by the name of the css class of the object you're inserting them into, fieldChoices, it would suggest that you're adding a list of choices and should therefore be using an unordered list to contain your items.

CptSkippy
+2  A: 

I would remove the <p> tag and combine the classes into the <a> tag.

$("<a href='#' class='cutsom_button btn lbOn addchoice'><span class='button_image'><span class='background_16 user_reply'>Add</span></span></a>").appendTo(".fieldChoices");

$("<a href='#' class='cutsom_button btn lbOn deletechoice'><span class='button_image'><span class='background_16 user_reply'>Delete</span></span></a></p>").appendTo(".fieldChoices");

or, I would use <span> instead of <p>

$("<span class='addChoice cutsom_button'><a href='#' class='btn lbOn addchoice'><span class='button_image'><span class='background_16 user_reply'>Add</span></span></a></span>").appendTo(".fieldChoices");

$("<span class='deleteChoice cutsom_button'><a href='#' class='btn lbOn deletechoice'><span class='button_image'><span class='background_16 user_reply'>Delete</span></span></a></span>").appendTo(".fieldChoices");
Chris
+1  A: 

I think the best solution would be to choose a better tag to markup your buttons. <button> springs to mind...

But anyway, you could use display: inline, or, if you need to be able to set their widths, you can use display: inline-block

nickf