Reputation:
I am trying to create a button with bootstrap classes like below.
$("<button/>",
{
type: 'button',
class:'close',
data-dismiss: 'alert',
aria-hidden:'true'}).appendTo("#testt");
Since data-dismiss
has hyphen, it shows Unexpected token '-'
.
How to fix this?
Thanks!
Upvotes: 0
Views: 66
Reputation: 572
Change your code to this.
$("<button/>", {
type: "button",
class: "close",
dataDismiss: "alert",
ariaHidden: "true",
}).appendTo("#testt");
Upvotes: 0
Reputation: 27051
You can write data-dismiss
as a string, it will not be a problem
like:
$("<button/>", {
type: 'button',
class: 'close',
'data-dismiss': 'alert',
'aria-hidden': 'true'
}).appendTo("#testt");
Upvotes: 0