如何通过焦点显示元素的标题 [英] how to show title of the elements through focus

查看:61
本文介绍了如何通过焦点显示元素的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



是否有任何Jquery或任何其他方式显示焦点上的元素标题就像悬停时显示的标题???



我发现这个jquery但它不起作用.....任何人都可以帮忙...在此先感谢!!!!!!!!!!

Hi guys,

Is there any Jquery or any other way to display the title of the elements on giving focus just as the title displayed on hovering???

I have found this jquery but its not working.....Can anyone help please... Thanks in Advance!!!!!!!!!!

$(function () {
        var xOffset = 20;
        var yOffset = 30;
    $('input').focus(function (e) {
        this.t = this.title;
        this.title = "";
        $("body").append("<span id='tooltip'>" + this.t + "</span>");
        $("#tooltip").css("top", (e.pageY - xOffset) + "px").css("left", (e.pageX + yOffset) + "px").fadeIn("fast");
    });

    $('input').blur(function (e) {
        this.title = this.t;
        $("#tooltip").remove();

        $("#tooltip").css("top", (e.pageY - xOffset) + "px").css("left", (e.pageX + yOffset) + "px");
    });

});





HTML代码如下 -



HTML code is as follows-

<body id="loginbody" class="login-body">

    <input type="hidden" id="page-culture-value" value="en" />

        <div class="login-tr">
        <div class="login-td">

            <div class="login-page"  >
                <div class="login-block">
                    

                    <form id="main" action="?" method="post">
                        <div class="form-item">
                            <label for="email" tabindex="1">Username</label>
                            <input type="text" tabindex="1" title="Enter Email here" id="email" name="email" class="form-text with-text">
                        </div>

                        <div class="form-item">
                            <label for="password" tabindex="30">Password</label>
                            <input type="password" tabindex="30" title="Enter Password here" id="password" name="password" class="form-text" value="">
                        </div>

                        <div class="check-label">
                         <input title="Click to Stay Signed In" tabindex="40" type="checkbox" value="1" name="remember" id="remember" >
                            <label for="remember">Stay signed in</label>
                        </div>

                                <input type="hidden" name="rurl" value="" />
                            <input title="Click to Submit" tabindex="60" type="submit" value="Sign in" class="blue-button">
</form>
                    <div class="links">




                        <p><a href="#" id="reset-password" tabindex="70" style="color: #000000;" title="Pop-Up window for resetting Password">I forgot my password</a></p>
                    </div>

                        <a href="?lang=fr"  class="grey-button button-fr" title="Press to select French" tabindex="75"><span>FRANÇAIS</span></a>

                </div>
                <div class="foot">&copy; /div>

            </div>

        </div>


    </div>
    <div class="popup-form popup-win" id="popup-reset-password">
        <h1 id="resetpassheading">
            Reset password
        </h1>
        <form id="reset-password-form" action="/Home/ResetPassword" method="post" class="modules-form" enctype="multipart/form-data">

            <div class="form-item">
                <label for="email-reset">Username</label>
                <input title="Enter your Email " tabindex="8" type="text" id="email-reset" name="email-reset" class="form-text with-text" placeholder="Email Address" data-required="true">
            </div>

            <div class="buttons">
                <input title=" Click for OK" tabindex="9" type="submit" class="blue-button ok-button" value="Ok">
                <input title="Click for Cancel" tabindex="10" type="button" class="blue-button cancel-button" value="Cancel"...<>
            </div>
        </form>







< / div>

< / body>




</div>
</body>

推荐答案

(function(){
var xOffset = 20 ;
var yOffset = 30 ;
(function () { var xOffset = 20; var yOffset = 30;


(< span class =code-string>' input')。focus(function(e){
this .t = this .title;
this .title = ;
('input').focus(function (e) { this.t = this.title; this.title = "";


body)。append( < span id ='tooltip'> + .t + < / span>);
("body").append("<span id='tooltip'>" + this.t + "</span>");


这篇关于如何通过焦点显示元素的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆