格式化FancyBox的标题

我根本不知道javascript,但我正在尝试使用FancyBox格式化我的图片的标题/标题。 在我的标签的title属性中,我写了个人姓名,专业和职业。 我希望他们的名字显示在一行,然后主要和职业可以在下一个。 例如:

Joe Smith,BS ’02
专业:企业社会责任,职业:零售经理

我知道我不能在title="" ,所以在我的javascript函数中有一个简单的方法吗? 我希望我可以将我的id属性设置为该人的名字并在我的函数中调用它,然后将标题设置为其余部分,但这似乎不起作用。

这是当前function正常,只需要以某种方式拆分我的标题:

 ("a[rel=cdfs]").fancybox({ 'transitionIn' : 'elastic', 'transitionOut' : 'elastic', 'titlePosition' : 'over', 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) { return '' + (title.length ? '   ' + title : '') + '

Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '

'; } });

感谢您的任何想法或输入! 我很感激 :)

你可以用两行来打破你的头衔:

 'titleFormat': function(title, currentArray, currentIndex, currentOpts){ temp=title.split('|'); if(!temp[1]){temp[1]=""}; return '
'+temp[0]+'
'+temp[1]+'
' },

你可以看到我通过添加’|’来分割标题 字符,需要添加到标题文本中,但您可以采用不同的方式。 此外,在这个简单的示例中,诸如背景等格式化将丢失,但您可以轻松地修复它。

祝好运

ķ