The easiest way...
$('h3').text(function(i, text) {
return text.split(':')[0];
});
jsFiddle.
...but this won't cover you if there are child elements.
This code will...
var searchText = function(parentNode, regex, callback) {
var childNodes = parentNode.childNodes,
node;
for (var i = 0, length = childNodes.length; i < length; i++) {
node = childNodes[i];
if (node.nodeType == 0) {
var tag = node.tagName.toLowerCase();
if (tag == 'script' || tag == 'style') {
continue;
}
searchText(node);
} else if (node.nodeType == 3) {
while (true) {
// Does this node have a match? If not, break and return.
if (!regex.test(node.data)) {
break;
}
node.data.replace(regex, function(match) {
var args = Array.prototype.slice.call(arguments),
offset = args[args.length - 2],
newTextNode = node.splitText(offset);
callback.apply(window, [node].concat(args));
newTextNode.data = newTextNode.data.substr(match.length);
node = newTextNode;
});
}
}
}
}
searchText($('h3')[0], /:.*$/, function(node) {
$(node).next().remove();
});
jsFiddle.
I adapted this code from some code that doesn't use the jQuery library. You could make it slightly more elegant with jQuery (such as children(), each(), makeArray(), etc).