Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make the text bold using jquery

I have this out put.

<option value="18277">Dollar Max Hospice~Mx</option>
<option value="12979">Routine Adult Physical Exam Visit Limit</option>
<option value="12841">Is Reverse Sterilization Covered Out of Network?</option>
<option value="12918">MD CDH PPO Variables 2</option>
<option value="12917">DC CDH PPO Variables 2</option>
<option value="12833">Is Sterilization Covered No Network?</option>
<option value="12834">Is Sterilization Covered In Network</option>

I have a search box and button when i hit Dollar I need to bold the text in my list box. I need to itterate the list box data and make that text as bold.

like image 973
user957178 Avatar asked Sep 25 '11 18:09

user957178


People also ask

How do I make text bold in jQuery?

addClass("boldText"); *Note about the use of ! important : This is usually not recommended CSS as it's often used in the wrong way. However in this case if you add a class called boldText to an element, chances are, you will always want it to have bold text.

How do you make text bold in JavaScript?

To create a bold text using JavaScript, use the bold() text. This method causes a string to be displayed as bold as if it were in a <b> tag.


2 Answers

Using the jQuery, you can apply the css:

font-weight:Bold;

So just do:

$myElement.css("font-weight","Bold");
like image 147
Freesnöw Avatar answered Oct 16 '22 22:10

Freesnöw


For me on FF6 at least, it will show as a normal font in the select box, however in the actual list itself it will show bold if you do:

$('select option[value="18277"]').css({ 'font-weight': 'bold' });
like image 39
Bojangles Avatar answered Oct 16 '22 22:10

Bojangles