现在,我正在使用<body onload="function">,它根据所关注的元素来更改页面上的某些文本。它工作正常,但是每次焦点改变时(或者甚至每次单击页面的任何部分时,我都需要运行我的网站)。
当前代码如下:
<body onload="changeText()">
<script>
function changeText(){
function here;
}
</script>
<p>This is where text changes based on the function</p>
Run Code Online (Sandbox Code Playgroud)
谢谢!
您可以在文档上附加onclick事件。jsfiddle
?document.onclick = function(){
// your code
//alert("clicked");
}?
Run Code Online (Sandbox Code Playgroud)
如果您想改变重点,请使用
window.onfocus = function(){
// your code
//alert("focus");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7927 次 |
| 最近记录: |