tags:

views:

32

answers:

2

Hi all,

I wrapped a link with a div-element

$("a[href$='name']").wrap("<div />");

The div-element causes line breaks. To prevent this behaviour I'd like to style my div-element with style="white-space: nowrap;".

I tried

$("a[href$='name']").wrap("<div style='white-space: nowrap;'></div>");

For some reason it doesn't work. There is no error shown. The line break however is still active.

What's wrong with my snippet?

Thanks for your help.

+3  A: 

When you wrap an element inside a div it will surely break in line since the div element will consume the whole line. Why not wrap it with span instead if you want to maintain the continuity of the paragraph or sentence or phrase?

rob waminal
Thta' it. Thanks for the hint.
Faili
+1  A: 

If for any reason the element NEEDS to be a div, and cannot be a span. You could give the div:

display: inline-block;

to get similar behaviour.

Bazzz
in IE7, it will still break the line.
rob waminal