【问题标题】:Change onclick="showMore()" onmouseover更改 onclick="showMore()" onmouseover
【发布时间】:2014-02-10 11:34:01
【问题描述】:
<input id="button" type="button" value="Expand" onclick="showMore()">

<div id="d3">
<div class="button12" onclick="document.location='#'">Home</div>
<div class="button12" onclick="document.location='#'">About</div>
<div id="d1">
    <input type="button" value="Shrink" onclick="showLess()">
</div>

<script type="text/javascript">//<![CDATA[ 

var button = document.getElementById("button");
var d3 = document.getElementById("d3");
function showMore() {
    button.style.display="none";
    d3.style.display="block";
}

function showLess() {
    button.style.display="inline-block";
    d3.style.display="none";
}
//]]>  

</script>

如何将onclick="showMore()" 更改为hover..

我需要它在不点击的情况下显示。

【问题讨论】:

  • 使用一些 CSS 代码制作悬停样式
  • onmouseover="showMore()" 没用?

标签: javascript php jquery html css


【解决方案1】:

您可以使用onmouseover 代替onclick

喜欢这个

<input id="button" type="button" value="Expand" onmouseover="showMore()">

<div id="d3">
<div class="button12" onclick="document.location='#'">Home</div>
<div class="button12" onclick="document.location='#'">About</div>
<div id="d1">
    <input type="button" value="Shrink" onclick="showLess()">
</div>

【讨论】:

  • 感谢 Satish Sharma 提供快速解决方案。
  • 完成.. 但是如果我想在这个
  • 将此函数添加到 标签中,像这样&lt;img type="button" src="xxxxx.jpg" height="52" width="72" onmouseover="showMore()"&gt;
  • 请记住,这是一个适用于每个 html 标签的事件,正如您在 &lt;input id="button".. 中看到的那样。检查是否有一些功能
【解决方案2】:

像这样使用 css 样式

#btn2:hover
{
//your design here
}

或像这样使用onmouseover

<input id="button" type="button" id="btn2" value="Expand" onmouseover="showMore()">

【讨论】:

    【解决方案3】:
    $("#button").mouseover(function(){
        $("#button").hide();
    });
    

    【讨论】:

      【解决方案4】:

      你可以改成onmouseover="showMore()"

      如果您无法编辑(无法访问)代码,您可以在页面加载或任何 perticulat 事件中尝试类似的操作。

      $('#yourID').attr ('onClick', "onmousover");
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-10-30
        • 2015-05-29
        • 2011-06-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-05-23
        • 1970-01-01
        相关资源
        最近更新 更多