87,964
社区成员
发帖
与我相关
我的任务
分享
function GetLength(str) {
if (str == null) return 0;
if (typeof str != "string"){
str += "";
}
return str.replace(/[^\x00-\xff]/g,"01").length+4;
}
(function($) {
$.fn.extend({
bigTitle: function(options) {
var settings = $.extend({
big_text: "",
big_length: "",
big_width: 500
});
return this.each(function(e) {
var big_text = $(this).text();
var big_length = $(this).text().length;
var big_fontsize = $(this).css("font-size").replace("px","")*1;
big_length = Math.ceil(GetLength($(this).text())/2);
alert(big_length);
var big_width = big_fontsize*big_length+64;
big_width = (big_width < 500) ? 500 : big_width;
$(this).html("<div class='big_title_left'><div class='big_title_right' style='width:" + big_width + "px;'><span style='padding-left:45px;padding-right:45px;'>" + big_text + "</span></div></div>").css("width", big_width + "px");
});
}
});