Mark Lester
Mark Lester

Reputation: 373

How do I set the button text in bootstrap

I have included this in the html

<!-- Bootstrap UI stuff -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

and then in my javascript I have tried making the buttons nice by going

        $('<button type="button" class="btn btn-primary">',{
            id:"opener-add-"+tableName,
            html:"Add"
            }).appendTo("#form-"+tableName);

What I end up with is a blue button but the "Add" is missing (it was the same with anormal button, I lost the text).

Upvotes: 0

Views: 74

Answers (2)

Subash Selvaraj
Subash Selvaraj

Reputation: 3385

Tryt this,

$('<button type="button"  id="opener-add-'+tableName+'" class="btn btn-primary">Add</button>').appendTo("#form-"+tableName);

Upvotes: 0

Rob M.
Rob M.

Reputation: 36511

HTML and text are not really DOM attributes (you are in effect running: document.body.setAttribute('html', 'Add')), you have to set them using the text or html methods:

$('<button type="button" class="btn btn-primary">',{
            id:"opener-add-"+tableName,
     }).text('Add').appendTo("#form-"+tableName);

Upvotes: 1

Related Questions