"); ...">

Wrapping a link with a div element and disabling line break divs

I wrapped the link with the div element

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

The div element causes line breaks. To prevent this behavior, I would 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 this does not work. No error is displayed. However, line breaks are still active.

What happened to my fragment?

Thank you for your help.

+4
source share
2 answers

When you complete an element inside a div , it will undoubtedly be split into lines, since the div element will consume the entire line. Why not wrap it with a span instead if you want to keep a paragraph or sentence or phrase uninterrupted?

+4
source

If for any reason the NEEDS element must be a div and cannot be a range. You can give a div:

 display: inline-block; 

to get similar behavior.

+1
source

All Articles