87,989
社区成员
发帖
与我相关
我的任务
分享$(function(){
$(":input[name=submit]").click(function()
{
var $wenben = $("#wenben");
var wenben = $wenben.val();
var guol = new Array();
guol[0] = '<img style="margin-bottom:-1px;" src="/output.php?word=%C5%C5%C3%FB&r=83&g=83&b=83">'; // 排名
guol[1] = '<img style="margin-bottom:-1px;" src="/output.php?word=%B9%D8%BC%FC%B4%CA&r=83&g=83&b=83">'; //关键字
guol[2] = '<img style="margin-bottom:-1px;" src="/output.php?word=%C3%AA%CE%C4%B1%BE&r=83&g=83&b=83">'; // 锚文本
guol[3] = '<img style="margin-bottom:-1px;" src="/output.php?word=%B0%FC%BA%AC&r=83&g=83&b=83">'; // 包含
guol[4] = '<img style="margin-bottom:-1px;" src="/output.php?word=%C0%ED%BD%E2&r=83&g=83&b=83">'; // 不理解
guol[5] = "<br />";
guol[6] = /<font[^>]*>/gi;
guol[7] = "</font>";
var tihuan = new Array();
tihuan[0] = "排名";
tihuan[1] = "关键字";
tihuan[2] = "锚文本";
tihuan[3] = "包含";
tihuan[4] = "不理解";
tihuan[5] = "";
tihuan[6] = "";
tihuan[7] = "";
for(var i =0;i < guol.length;i++){
while(wenben.indexOf(guol[i]) != -1) {
wenben = wenben.replace(guol[i],tihuan[i]);
}
}
$("#result").html(wenben);
});
});
var tagTemp = {
'img': 'aa',
'font': 'bb'
};
String.prototype.format = function(tag) {
var temp = this;
for(each in tag) {
temp = temp.replace((new RegExp("<" + each + "[^>]*?>", 'gi')), tag[each]);
}
return temp;
}
var str = "wertwerte<img style=\"margin-bottom:-1px;\" src=\"/output.php?word=%C5%C5%C3%FB&r=83&g=83&b=83\">sdfgertqwet<font color=\"red\">wertwert";
alert(str.format(tagTemp));