dannyBwheeler
dannyBwheeler

Reputation: 23

Bold text using JQUERY: Traversing and changing the font

I'm working on customizing a page, and want to change a specific field's text to render as bold. When I inspect the field with chrome it has

<span id="_Datacomp_name" class="VIEWBOX" style="WIDTH:&quot;100px&quot;">testCompany</span>

How can I use JQUERY to select this field and then make it bold?

I understand HTML, but am new to JQUERY.

I thought using this would work:

<script src="ajax.googleapis.com/.../jquery.min.js"></script>

<script>
    $(document).ready(function(){
        $("#_Datacomp_name").AwesomeBoldFunctionHere;
</script>

Upvotes: 0

Views: 73

Answers (3)

Jonco98
Jonco98

Reputation: 402

In JavaScript you can do this,
document.getElementById("_Datacomp_name").style.fontweight = "bold";

In JQuery,
$("#_Datacomp_name").css("font-weight", "bold");

In CSS,
#_Datacomp_name { font-weight:bold; }

Upvotes: 0

silentw
silentw

Reputation: 4885

$(function() {
    $('#_Datacomp_name').css('fontWeight', 'bold');
});

Documentation: jQuery.css Working demo

And... If you're wondering about the $(function() { }) syntax jQuery.ready:

All three of the following syntaxes are equivalent:

  • $( document ).ready( handler )
  • $().ready( handler ) (this is not recommended)
  • $( handler )

Being the handler your function() { }

Upvotes: 0

John Bupit
John Bupit

Reputation: 10618

Try this:

$("#_Datacomp_name").css("font-weight", "bold");

Upvotes: 2

Related Questions