Using your SP.Web object, you can get the parent information (SP.WebInformation).
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var rootInfo = web.get_parentWeb();
var rootWeb = context.get_site().openWebById(parentInfo.get_id());
context.load(rootInfo);context.load(rootWeb);
context.executeQueryAsync(Function.createDelegate(this,onListDataSucceeded),Function.createDelegate(this, onListDataFailed));
function onListDataSucceeded(sender, args)
{
alert(this.rootWeb.get_title());
}
function onListDataFailed(sender, args)
{
alert('error');
}