以驗證碼的刷新為例
</form>
在html文件的<head></head>之間引入外部文件
//外部文件code.js設置局部刷新函數
function code () {
var code = document.getElementByIdx_x_x('code');
code.onclick = function () {
this.src='code.php?tm='+Math.random();
};
};
<span id="update">點擊刷新驗證碼</span>
</form>
方法二:引入外部文件
在html文件的<head></head>之間引入外部文件
//外部文件code.js設置局部刷新函數
function code () {
var code = document.getElementByIdx_x_x('code');
var update = document.getElementByIdx_x_x('update');
update.onclick = function () {
code.src='code.php?tm='+Math.random();
};
};
新聞熱點
疑難解答