Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change button text to bold

Tags:

html

jquery

css

I have this code which shows/hides the div on click.

<!doctype html>
 <html lang="en">
   <head>
     <meta charset="utf-8">
       <title>slide demo</title>
         <style>
           #showmenu {
               background: '#5D8AA8';
               border-radius: 35px;
               border: none;
           height:30px;
           width:140px;
           }

        </style>
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
     </head>
    <body>
      <div ><button id="showmenu" type="button"><b>Show menu</b></button></div>
     <div class="menu" style="display: none;">
        Can the button value change to "show" or "hide"
     </div>
     <script>
        $(document).ready(function() {
        $('#showmenu').click(function() {
        $('#showmenu').text($('.menu').is(':visible') ? 'Show Menu' : 'Hide Menu');
        $('.menu').toggle("slide");
       });
     });
     </script> 
 </body>
</html>

Everything works fine. But I want the text to be in bold. How can I do that? It is bold for the first time. But when the text changes from jQuery, it is displayed as normal text. What are the changes I have to make ?

like image 452
Bittu Avatar asked Oct 28 '25 17:10

Bittu


2 Answers

Try with inline-style like

<button id="showmenu" type="button" style="font-weight:bold;">show menu</button>

Using internal/external-style use like

#showmenu {
     font-weight : bold ;
}
like image 145
Gautam3164 Avatar answered Oct 30 '25 07:10

Gautam3164


You can use the CSS font-weight setting.

Add this to your CSS:

#showmenu {
   font-weight: bold;
}
  • After adding this you can remove the <b> tags from the button's content.
like image 34
Itay Avatar answered Oct 30 '25 06:10

Itay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!