Reputation: 625
How can I center those two buttons in JS:
// create a sort by alphabet button
var sortabc = $('<a href="javascript:void(0)" class="btn">Sort alphabetically</a>').toggle(
function(){
$("#tags ul li").tsort({order:"asc"});
},
function(){
$("#tags ul li").tsort({order:"desc"});
}
);
$('#tags').append(sortabc);
// create a sort by alphabet button
var sortstrength = $('<a href="javascript:void(0)" class="btn">Sort by strength</a>').toggle(
function(){
$("#tags ul li").tsort({order:"desc",attr:"class"});
},
function(){
$("#tags ul li").tsort({order:"asc",attr:"class"});
}
);
$('#tags').append(sortstrength);
At this moment I get them like this: Button 1 Button 2
I want them in the middle of the div.
Upvotes: 1
Views: 121
Reputation: 150080
With CSS, in your style sheet:
#tags {
text-align : center;
}
With jQuery, setting that same CSS property:
$('#tags').css("text-align", "center");
Demo: http://jsfiddle.net/z77Lm/
Upvotes: 5
Reputation: 386
Try using tag inside the div:
<div>
<center>
...BUTTONS
</center>
</div>
Upvotes: -2