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条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!