donglei1699 2013-05-06 18:51
浏览 23
已采纳

Facebox对话框 - jQuery选择器修改输入字段,但没有事件触发器工作[关闭]

I cannot get a .change(), .click(), or .keydown() trigger to work in any browser on my facebox form.

-- EDIT --- The problem is that facebox CLONES html to display it in the dialog box element. Because of this, jquery selectors work, but event triggers do not (based on the duplicate). The fix is to modify facebox and remove the .clone() behavior.

-- END EDIT --

The following works on document ready:

$('input#testE').css('background-color', 'red');

where #testE is a text input. On load the textbox background is red. however...

$('input#testE').keydown(function() { 
    $('input#testE').css('background-color', 'red');
});

does not trigger. I've also tried .change(), and .click(). Neither will it print to console for testing. My code works fine in jsFiddle, but will not work in my environment. Any thoughts on this?

edit....

to clarify on the document ready issue:

    $(document).ready(function() { //on document load

        console.log('test'); // this works

        $('input#testE').keydown(function() { //won't fire
            $('input#testE').css('background-color', 'red');
        });


                   $('input#testE').css('background-color', 'blue'); //works
            });
  • 写回答

2条回答 默认 最新

  • dsns47611 2013-05-06 19:42
    关注

    When you click the "Request an Account" button, you make a copy of a form that already exists in the document and display it.

    When you copy the form, you take its current inline style (the yellow colour) with it, but you don't take the event handler.

    If you change #req_acct to display: block, you can see the original form and see the colour change.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥15 使用LM2596制作降压电路,一个能运行,一个不能
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错