javascript - 我无法在alert()中显示计数

标签 javascript html

我写了一个示例 html

<html>
<head>
<title>Demo</title>
</head>
<body>

<h1> Event <h1>

/* <p> <a onmouseover = "alert('Pop  up window text')">  </a></p    
<p> <a href="http://www.google.com" onmouseover='++count; alert ("Moved")'> jjj</a></p>

</body>
</html>

但是我无法在警报中显示计数,有人可以帮助我吗

最佳答案

看看这个 fiddle ,我只用过你的代码

http://jsfiddle.net/xf5gE/

这就是我所做的

<html>
    <head>
        <script>
            var count = 0; 
        </script>
    </head>
<body>
<h1> Event <h1>
<p> <a onmouseover = "alert('Pop  up window text')">  </a></p>   
    <p> <a href="http://www.google.com" onmouseover='alert ("Moved :: Count = "+count); ++count'> jjj</a></p>

</body>
</html>

关于javascript - 我无法在alert()中显示计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6174744/

相关文章:

javascript - 在 Javascript 循环中分配变量

html - 页脚后的空白,仅在 Firefox 和 IE 中

javascript - 使用 Javascript 访问 IFrame 的 HTML

javascript - 解读 Uniswap V3 价格

javascript - 在空数组上调用 Array.prototype.reverse()?

javascript - 如何限制添加字段?

html - 每个网页的最大 <iFrame> 标记数

android - 摩托罗拉 xoom 平板电脑浏览器上的 m3u8 http 直播

html - 仅内联文本元素的 bg 颜色填充的一些问题

javascript - 如何向移动网站提供更少的图片