简体   繁体   English

使用jQuery / Javascript将鼠标悬停在按钮上时,将文本插入文本区域并帮助文本

[英]Insert text into textarea and help text when mouseover buttons with jQuery/Javascript

I have a buttons who insert different text into the textarea, now I also want different help text then mouseover the buttons, but I cant get it to work 我有一个按钮,可以在文本区域中插入不同的文本,现在我还想要其他帮助文本,然后将鼠标悬停在按钮上,但是我无法使它工作

Tip code I try to combine with the fiddle, but i cant get it to work together 提示代码,我尝试与小提琴结合使用,但是我无法使其协同工作

<button id="button" onmouseover="mOver1(this)" onmouseout="mOut1(this)">Insert1 asdad</button>
<button id="button" onmouseover="mOver2(this)" onmouseout="mOut2(this)">Insert2</button>

<script>
    function mOver1(obj) {
        obj.innerHTML = "<div id='help_container1'><p id='help_text'>Help Text1</p></div>"
    }

    function mOut1(obj) {
        obj.innerHTML = "<button id='button' onmouseover='mOver1(this)' onmouseout='mOut1(this)'>Insert1</button>"
    }




 function mOver2(obj) {
        obj.innerHTML = "<div id='help_container2'><p id='help_text'>Help<br>Text2</p></div>"
    }

    function mOut2(obj) {
        obj.innerHTML = "<button id='button' onmouseover='mOver2(this)' onmouseout='mOut2(this)'>Insert2</button>"
    }
</script>

Fiddle to insert text into textaarea when click button http://jsfiddle.net/rmDzu/19 单击按钮http://jsfiddle.net/rmDzu/19时将小提琴插入文本到textaarea中

Fiddle to get help text when mouseover buttons http://jsfiddle.net/fTpwF 当鼠标悬停按钮http://jsfiddle.net/fTpwF时,拨弄小提琴以获得帮助文本

Anyone can help me to combine this fiddles into 1? 有人可以帮助我将这些小提琴组合成1吗? It dont need to be this code in the fiddles at all. 完全不需要在小提琴中使用此代码。

I'm not sure what you mean precisely, but... Check it: 我不确定您的确切意思,但是...检查一下:

$("#button").on({
    'mouseenter': function() {

        // make function for button

        // make function for textarea

    },
    'mouseleave': function()

        // make function for button

        // make function for textarea
    },
    'click': function() {

        // etc....
    }


});

- --

Here is fiddle with your example: 这是您的示例的小提琴:

http://jsfiddle.net/rmDzu/23/ http://jsfiddle.net/rmDzu/23/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM