-4

Possible Duplicate:
Changing the way a JavaScript Alert() or Prompt() looks

I have a string in my JavaScript code here:

_msg = "You have errors on Question Number: " + _qid + "\n";

I am displaying _msg using alert.

How can I make it bold?

Community
  • 1
  • 1
user1181690
  • 1,333
  • 2
  • 10
  • 12

3 Answers3

2

Your answer is way too vague to know what you're actually doing with that string, but in the off chance you're just sticking it in the DOM somewhere:

_msg = "<b>You have errors on Question Number: " + _qid + "</b>\n";

Edit: You're displaying it in an alert, sorry there isn't any control over the formatting in that case.

speshak
  • 2,427
  • 3
  • 27
  • 34
1

You can't style HTML content in alert pop-ups.

Your best bet is looking into a custom pop-up, which you can style with CSS and toggle with Jquery.

This tutorial is fairly simple as it only requires the Jquery library:

http://webdesignersdesk.com/2010/05/create-custom-popup-model-window-with-jquery/

There are also several plugins available for custom pop-ups too.

skippr
  • 2,536
  • 3
  • 23
  • 38
0

You cannot bold text in an alert. Sorry.

However, you can add something in the DOM that looks like an alert.

icktoofay
  • 122,243
  • 18
  • 242
  • 228