Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用jQuery的工具提示_Php_Javascript_Html - Fatal编程技术网

Php 使用jQuery的工具提示

Php 使用jQuery的工具提示,php,javascript,html,Php,Javascript,Html,我试图调出document.getElementByID以从当前表单中获取ID。但它不会悬停在我输入的特定文本上,而不是输出“文本”。作为参考,我已经修改了一些内容,但工具提示文本仍然没有显示 Updated code- In my html page: <script> $(document).ready(function () { var tooltip_Text = $('#tooltip_Text'); var tooltip = $('#

我试图调出document.getElementByID以从当前表单中获取ID。但它不会悬停在我输入的特定文本上,而不是输出“文本”。作为参考,我已经修改了一些内容,但工具提示文本仍然没有显示

Updated code-
In my html page:

<script>
$(document).ready(function () 
{
            var tooltip_Text = $('#tooltip_Text');
    var tooltip = $('#tooltip');
    $('#Hobby').hover(
        function() 
                    {
            tooltip.fadeIn(200);
        },
        function() 
                    {
            setTimeout ( function () {
                tooltip.fadeOut(200); student.php();
            }, 1000);
        }
    );
    $('#Hobby').bind('change', function() 
            {
        student.php('user has changed the value');
    });​
});​
</script>

//my list/menu
<select name="OffenceName" id="Hobby" ><span id="Hobby"></span>
<?php $arr = array('', 'cycling', 'badminton', 'jetskiing', 'ice-skating');
  for($i = 0; $i < count($arr); $i++)
  {
     echo "<option value=\"{$arr[$i]}\" {$selected}>{$arr[$i]}</option>\n"; 
  }
?>
</select>
<tool id="tooltip" class="tooltip">
<?php $toolarr = array('','cycling is...', 'badmintion is...', 'jetskiing is...', 'ice-skating is...');
  for($t = 0; $t < count($toolarr); $t++)
  {
      if($toolarr[t] == $arr[i])
      {
         echo "sample display";
      }
  }
<span id="tooltip_Text"></span>
更新的代码-
在我的html页面中:
$(文档).ready(函数()
{
var tooltip_Text=$('tooltip_Text');
变量工具提示=$(“#工具提示”);
$('爱好')。悬停(
函数()
{
工具提示:fadeIn(200);
},
函数()
{
setTimeout(函数(){
fadeOut(200);student.php();
}, 1000);
}
);
$('#Hobby').bind('change',function()
{
php('user已经更改了值');
});​
});​
//我的清单/菜单

您不应该使用本机javascript选择器选择元素,而应该使用jQuery选择器。目前,您的代码无法工作,因为您调用的方法只有在元素被jquery对象包装的情况下才存在

所以不是

document.getElementById("Hobby").hover(...
使用

您的代码应该抛出如下几个错误:

TypeError: Object #<HTMLDivElement> has no method 'hover'
TypeError:对象#没有方法“hover”
编辑:

两个错误:

//我的列表/菜单
不是有效的HTML注释

student.php()
也无效

试试这个

$(document).ready(function () 
{
    $("#Hobby").hover(function(){
        $("#tooltip").fadeIn("slow");
    },
    function(){
        $("#tooltip").fadeOut();
    });


    $('#Hobby').change(function() {
      $("#tooltip_Text").text("user has changed the value"); // or you can use .html("...") intead of .text("...")

    });

});​

使用完整的javascript或Jquery将document.getElementById(“Hobby”)替换为$(“#Hobby”)。不要把它们混在一起up@Tuscan我换了,但还是一样。所以我不能把它们混在一起?我必须拿出我的document.getelementbyid?尝试更改,但仍然是相同的结果“您的student.php()函数在哪里?”?这到底是什么?student.php是我的页面。而不是student.html。我的页面是student.phpy您不能在javascript中执行这样的调用。php()调用student对象上的函数php()。两者都不存在。@JLearner你完全做错了。。。答案现在离那很近抱歉打扰了,点击后它不会提醒。@JLearner我的英语不太好。我不明白你的意思??但是如果你想把事件改成点击事件,你可以在“改变”的中间写上“点击”。不,不是这个。而不是警觉。如何调用工具提示_文本?我无法放置工具提示文字。(‘用户已更改值’)不是吗?好的,它会显示出来!我没有意识到它在我的页面顶部。它不应该在我的控制范围内吗?@JLearner是的,它不应该在select控制范围内。如果您想显示页面顶部,可以将其移动到标记之后。
$(document).ready(function () 
{
    $("#Hobby").hover(function(){
        $("#tooltip").fadeIn("slow");
    },
    function(){
        $("#tooltip").fadeOut();
    });


    $('#Hobby').change(function() {
      $("#tooltip_Text").text("user has changed the value"); // or you can use .html("...") intead of .text("...")

    });

});​