0

I need to make "bold" the second column of this html table:
http://jsfiddle.net/beKC4/4/

How can I do using JQuery?
I tried this but is not working:

$("h3.ms-standardheader").children("td").text("<b>"+this.text()+"</b>")
Nk SP
  • 822
  • 4
  • 19
  • 37

4 Answers4

4

you can also use css

see here http://jsfiddle.net/beKC4/6/

table tr td:nth-child(3){
    font-weight:bold;
}
Grasper
  • 1,293
  • 12
  • 26
2

Use .html() instead

$(".ms-standardheader").closest('tr').find("td").html(function () {
    return "<b>" + $(this).text() + "</b>"
});

Also, the selector is incorrect, you need to use closest, then find the <td>

DEMO

Or if you don't want ms-standardheader to also get <b> you can use siblings()

$(".ms-standardheader").closest('td').siblings("td").html(function () {
    return "<b>" + $(this).text() + "</b>"
});

DEMO

Anton
  • 32,245
  • 5
  • 44
  • 54
0

You can use this. Create a css class and add this class with js using :nth-child(). Think is simplier.

css

.bold{
    font-weight: bold;
}

js

$('table td:nth-child(3)').addClass('bold');

fiddle

Alex Char
  • 32,879
  • 9
  • 49
  • 70
0

http://jsfiddle.net/b4AwC/

I would use nthchild selector, if you want ever other one bold you can put in even or odd I hope this help

$("tr td:nth-child(2)").css({"color":"red"});
$("tr td:nth-child(even)").css({"background":"grey"});
aahhaa
  • 2,240
  • 3
  • 19
  • 30