jQuery Focusout输入不起作用 [英] jQuery Focusout of input not working

查看:58
本文介绍了jQuery Focusout输入不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对表中的数据进行内联编辑,为此,我将单元格中的文本更改为输入.

I'm trying to create in-line editing of data in a table, to do this I am changing the text in the cell into an input.

$(document).ready(function(){
    $('td.edit').on("click",function(){
        $(this).html("<input type=\"text\" value=\"" + $.trim($(this).text()) + "\" />");
        $(this).off();
    });
});

这很好.

然后,我想在单击时使用ajax写入数据,但是我似乎无法使聚焦工作正常进行...

Then I'm wanting to write the data away with ajax when I click away, however I can't seem to get the focusout working...

我已经在$ {document).ready中尝试了以下所有方法,但都没有成功:

I've tried the following, all inside the $(document).ready, all without success:

    $('td.edit').on("focusout","input",function(){
        alert("bye");
    });

    $('td.edit input').on("focusout",function(){
        alert("bye");
    });

    $('td.edit input').focusout(function(){
        alert("bye");
    });

    $('td.edit').on("focusout",function(){
        alert("bye");
    });

    $('td.edit').focusout(function(){
        alert("bye");
    });

推荐答案

尝试一下,

$('td.edit').on("blur","input",function(){
    alert("finally bye");
});

如果parent td.edit不起作用,则将document用作parent selector之类的

If parent td.edit not works then use document as parent selector like

$(document).on("focusout","td.edit input",function(){
    alert("finally bye");
});

小提琴

这篇关于jQuery Focusout输入不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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