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.
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?
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.
精彩评论