
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
jquery-unorphanize
Advanced tools
#jQuery Unorphanize
A jQuery helper for preventing orphans. Originally forked from simeydotme’s plugin, but with added functionality and significant refactoring.
##Basic Use
$(".selector").unorphanize();
Unorphanize will replace the last space with
without disturbing any inner HTML.
##Advanced Usage
$(".selector").unorphanize({
words: 3,
wrapEl: "span",
className: "u-nowrap"
});
Unorphanize will wrap the last 3 words in a <span>
with class u-nowrap
without disturbing the inner HTML.
Using a wrapper element is typically better than
because you can use CSS to prevent orphans only on wider screens. This prevents long words from extending beyond the parent container on mobile devices.
@media all and (min-width: 320px) {
.u-nowrap {
white-space: nowrap !important;
}
}
##Tips Use sparingly, only on elements where orphans are particularly undesirable. Avoid applying to all paragraphs and headings, which could hurt performance.
##Why is this plugin necessary? If your element only contains plain text, you could do something simpler like this:
var $el = $('.selector');
var words = $el.text().split(' ');
var lastWord = words.pop();
$el.html(words.join(' ') + ' ' + lastWord);
However, if the target element contains any HTML elements, they will be removed. Unorphanize preserves the inner HTML so you can safely use it on elements with children.
FAQs
A jQuery helper for preventing orphans
We found that jquery-unorphanize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.