You could also do this with a regular expression. Maybe something
like this:
var mystring = $('#title a:first').html();
var firstword = mystring.replace(/(^\w+)/,'<strong>$1</strong>');
$('#title a:first').html(firstword);
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Nov 12, 2007, at 11:52 AM, [EMAIL PROTECTED] wrote:
Somebody else probably has a more consice method but you could try
something like this
var mystring = "One Two Three"; //replace with your string
var stringarray = mystring.split(" ");
var firstword = mystring.split(" ")[0];
myarray = jQuery.grep(stringarray, function(n, i){
return (i > 0);
});
$("div#title a").append("<strong>" + firstword + "</strong>
").append(myarray.join(" "));
On Nov 11, 8:56 pm, Viktor Tarm <[EMAIL PROTECTED]> wrote:
I am trying to make the first word of a sentence (a title from a
generated feed) bold.
TURN THIS:
<div id="title">
<a href="123.html">One Two Three</a>
</div>
INTO THIS:
<div id="title">
<a href="123.html"><strong>One</strong> Two Three</a>
</div>
I sure there is a way to do with jQuery, but I can't quite figure it
out. I have tried something like this, with no luck:
$("#title.a").contents(0).wrap("<strong></strong>");
Any help would be greatly appreciated.