简体   繁体   中英

Specify font size of javascript alert box message

I have to show the message on alert box with font size - 6. I have done like below.

     var str = "Formatting some text.";
     str = str.fontsize("6").fontcolor("#006400").bold();
     alert(str);

But the output get as
<b><font color="#006400"><font size="6">Formatting some text.</font></font></b> Please help to correct the issue

I think No as per my knowledge as this is controlled by the browser

You would have to use a JavaScript based dialog windows alternative like jQuery UI Dialog .

there is another alternative to jQuery UI Dialog box is sweetalert

It is possible to set bold text at alert()

 alert("𝗙𝗼𝗿𝗺𝗮𝘁𝘁𝗶𝗻𝗴 𝘀𝗼𝗺𝗲 𝘁𝗲𝘅𝘁.") 

jsfiddle http://jsfiddle.net/7YgLB/10/

Use this code. It will help

HTML

<div id="Custom_Alert" title="Alert">
  <p style="font-size:6px">Formatting some text.</p>
</div>

JavaScript

$( function() {
  $( "#Custom_Alert" ).dialog();
} );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM