user1781367
user1781367

Reputation: 602

Dropdown select string font style change

I have this dropdown filter that is generated from a DB. It gives the selection list for users to select from.

This is the sample product list.

-View All-
-iPhone-
-Android-
-WindowsPhone-
-Blackberry-

However, I want to make the 'iPhone' string to bold face in this script code. Please advice kindly?

var dropdown= function( response ){
    var productFilter = $('.dropdownControl');

    productFilter .change( userMgmtFilterDDChange );
    var pdlist= response.Results.Products;

    var dropdownString = '';
    dropdownString += '<option selected="selected">View All</option>';
    $.each( pdlist, function( index, item ){
        dropdownString += '<option>' + item.Name + '</option>';
    });
    productFilter .append( dropdownString );
}

Upvotes: 0

Views: 397

Answers (2)

mirk
mirk

Reputation: 432

Change this

 dropdownString += '<option>' + item.Name + '</option>';

To that

dropdownString += '<option>' + (item.Name==Iphone ?'<b>'+item.name+'</b>': item.name) + '</option>'; 

Upvotes: 0

Yann Chabot
Yann Chabot

Reputation: 4869

Add a class in jQuery if the name is iPhone, that way :

   $.each( pdlist, function( index, item ){
    if (item.Name == 'iPhone'){
      dropdownString += '<option class="bold">' . item.Name . '</option>';
    }
    else{
      dropdownString += '<option>' + item.Name + '</option>';
    }
 });

Then, in your css file, use this

   .bold{
        font-weight: bold;
    }

Upvotes: 1

Related Questions