Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (42 sloc) 1.29 KB

jQuery Stylewords

For the times when you wish that CSS had a :first-word(x) psuedo-class.

Getting Started

Download the production version or the development version.

In your web page:

<p>Lorem ipsum dolor sit amet.</p>
<script src="jquery.js"></script>
<script src="dist/jquery.styleWords.min.js"></script>
jQuery(function($) {

This will turn the paragraph into:

<p><span class="styleWords">Lorem ipsum</span> dolor sit amet.</p>

At this point, you have your CSS hook. Style those first few words however you wish!


Easiest Usage

// Filter through collection, and wrap the 
// first word in a span.

// Wrap the first three words in a span

// Wrap the first two words, and use a `strong` tag instead.
$('p').styleWords(2, {
    tag: '<strong>'

// Apply a custom classname
$('p').styleWords(2, {
    'class': 'my-custom-class'

Release History

  • 0.1.0 - First draft of plugin.


Copyright (c) 2012 Jeffrey Way
Licensed under the GPL license.

Jump to Line
Something went wrong with that request. Please try again.