js修改调用服务器html文件内容

JavaScript016

js修改调用服务器html文件内容,第1张

加载html文件时,把此文件的<body>..</body>的全部源代码传到一个function中进行处理,或替换,或屏蔽,这个具体的处理视LZ的要求而定!大概如下:

1、某html文件:

$(function(){

var bodyString = replaceFunctioin($("body").html())

$("body").html(bodyString)

})

2、某replaceFunction方法:

function replaceFunction(str){

var result = str.replace("中文","Chinese")

result += result.replace("英文","English")

//...

return result

}

作用:把html中的“中文”和“英文”用英语替换!!!

modify.js里面添加:

$(document).ready(function(){

$("#bodyDemo").html("Good Morning!")

})

modal.html页面里引用jquery.js和modify.js

在页面的<body id="bodyDemo">Hello World!</body> body标签加个id名称

$("#tab_conbox button").click(function () {

    $("#tabs li").eq($("#tab_conbox button").index(this) + 1).click()

})