悬停时的jQuery淡出元素

时间:2012-05-09 16:24:06

标签: javascript jquery

我有一个wordpress网站,当填写表单时,如果抛出错误,那么插件会显示<span>,其中包含错误文本。

我试图使用jQuery淡化该文本,我尝试了以下两种方法都无济于事......

$(".wpcf7-not-valid-tip").on("mouseenter", function(){
        alert( 'test');
});
$('.wpcf7-not-valid-tip').hover(
      function () {
       $(this).fadeOut();
});

我的HTML标记正在输出......

<span class="wpcf7-form-control-wrap telno">
    <input type="text" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required field wpcf7-not-valid" value="" name="telno">
    <span class="wpcf7-not-valid-tip">Please fill the required field.</span>
</span>

1 个答案:

答案 0 :(得分:0)

是否有可能在项目存在之前绑定事件?

试试这个,看看你是否有更多运气

$('.wpcf7-not-valid-tip').live('mouseenter', function(ev) {
    $(this).fadeOut();
});

$(".wpcf7-not-valid-tip").on("mouseenter", function(ev){
    $(this).fadeOut();
});
相关问题