You can use contents
, and filter by node type (3 is for text node):
$('div').contents()
.filter(function(){return this.nodeType === 3})
.wrap('<b />');
Example: http://jsfiddle.net/nJqKq/8
See also: Node Types, at MDC
More Related Contents:
- How to get text node after element?
- How can I know which radio button is selected via jQuery?
- Selecting and manipulating CSS pseudo-elements such as ::before and ::after using javascript (or jQuery)
- Should all jquery events be bound to $(document)?
- Get selected text from a drop-down list (select box) using jQuery
- Assign click handlers in for loop
- How can I select an element by name with jQuery?
- jQuery selector for inputs with square brackets in the name attribute
- jQuery selectors on custom data attributes using HTML5
- How can I get selector from jQuery object
- Select all elements that have a specific CSS, using jQuery
- jQuery function to get all unique elements from an array?
- Testing if a checkbox is checked with jQuery
- jQuery : select all element with custom attribute [duplicate]
- Selecting multiple classes with jQuery
- Not class selector in jQuery
- jQuery single selector vs .find()
- jQuery Selector + SVG Incompatible?
- Using jQuery to search a string of HTML
- Store jquery selector in variable
- jQuery: Check if div with certain class name exists
- Is there a ‘has focus’ in JavaScript (or jQuery)?
- jQuery :contains(), but to match an exact string
- Getting a jQuery selector for an element
- In jQuery, is selecting by class or id faster than selecting by some other attribute?
- Getting the “match” object in a Custom Filter Selector in jQuery 1.8
- Combine two selectors with one jQuery object
- What is the new proper way to use a child selector with a context node in jQuery?
- jQuery: Select data attributes that aren’t empty?
- Why do functional pseudos such as :not() and :has() allow quoted arguments?