You can't apply CSS to a text node, but you can find the text node,
wrap it in a span, and then apply the css to that span. This should
work:
$('div > p').contents().filter(function() {
return this.nodeType == 3 && this.nodeValue.indexOf('certain
string') > -1;
}).wrap('<span/>').parent().css('color', 'red');
--Karl
____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Jan 5, 2010, at 5:59 PM, bundy wrote:
I'm trying to avoid classes and ids if possible. If I have to use them
I won't really need jQuery.
What about something like
var six = $("div > p::nth-child(6)
and then
for (i=0; i<six.length; i++) {
if (six.item(i).textNode) == "_ _ ") {
six.item(i).style.color = "red" }
?
On Jan 6, 3:04 am, brian <zijn.digi...@gmail.com> wrote:
CSS only operates on tagged elements. You'll have to wrap the text
node in a span (with a certain class, for example).
On Tue, Jan 5, 2010 at 2:00 AM, bundy <ctil...@hinet.net.au> wrote:
Hi, I'm new to jQuery, finding feet.
I want to be able to say, "if the text node of a certain child
consists of certain string, do this with its css".
Gotten as far as changing the css of all the children, thus:
$(document).ready(function(){
$("div > p::nth-child(6).css("color", "red");
});
but
$(document).ready(function(){
$("div > p::nth-child(6).textNode("_ _").css("color", "red");
});
doesn't do it. Nor does textNode=...
Second question, Firefox error console isn't muchhelp in
interpreting
the error. Any suggestion for debugging?