Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a particular word in bold using jquery?

Tags:

jquery

How to display a particular word in bold using jquery.

function OnSuccess(response) {
            var user = $('#username').val();
            if (response.d == 1) {


                $('#result').text(user + ' already Exists');
                $('#Button1').attr('disabled', true);

            } else {
                $('#result').text('Username '+user +' Ok');
                $('#Button1').attr('disabled', false);
            }


        }

Here i want to make the username(user) to be bold ,rest of the sentence must be normal.Is it possible by using jquery?

like image 500
Gopesh Avatar asked Feb 29 '12 09:02

Gopesh


1 Answers

Use html instead of text

function OnSuccess(response) {
    var user = $('#username').val();
    if (response.d == 1) {
        $('#result').html('<b>' + user + '</b> already Exists');
        $('#Button1').attr('disabled', true);
    } else {
        $('#result').html('Username <b>' + user + '</b> Ok');
        $('#Button1').attr('disabled', false);
    }
}
like image 140
Andreas Louv Avatar answered Nov 15 '22 00:11

Andreas Louv