English 中文(简体)
改动
原标题:.change() only work on select when multiple is on

http://api.jquery.com/change/rel=“nofollow”>:change(/a>。 j 质量功能。

请允许我向我解释一下,为什么它在那里工作,以arrow倒,改变价值,但如果我删除了“<条码>多>在选择上的属性,我必须总是在火上打进来?

是否有办法确定这一点?

最佳回答

认为只有在输入要素的价值发生变化时才会发生<代码>变更<>>。 当用户与多价值选择互动时,无论是通过改用或使用键盘,其价值都会发生变化——你可以看到,在页上的正文中,该元素的<代码>价值已经展示。

但是,对于单一价值选择,数值不是。 当你打开下跌和 h倒价值时,或者当你与你的主板相同时,就发生了改变。 因此,<代码>change活动是正确的。


如果你想要“工作”解决该问题,你就能够总是利用关键活动来控制价值和用途的变化。 这是一种简单的例子,说明这种职能可能包括:

$( select ).focus(function() {
    var v = this.value,
        t = $(this),
        c = t.children( :selected ); // Store the currently selected 
                                     // option element in a variable

    t.keydown(function(e) {
        switch (e.keyCode) {
        case 38:
        case 37:
            c = c.prev().length ? c.prev() : c;
            break;
        case 40:
        case 39:
            c = c.next().length ? c.next() : c;
            break;
        }

        // Do something with this information
        console.log(c.text());
    });
}).blur(function() {
    $(this).unbind( keydown );
});

www.un.org/Depts/DGACM/index_spanish.htm 见这方面的简单解调:

问题回答

I think that behaviour is caused by the way browsers handle keyboard events on select boxes. For single line select fields, the onchange event is triggered when the value has changed and the focus is moved out of the field, either by pressing enter or tab or by clicking somewhere outside the field. This makes sense in certain scenarios: If you for example want to redirect a user to a different page depending on his selection, you still want him to be able to scroll through the field with the arrow keys without reloading the page after each keypress.

如果你明确希望每当用户使用关键人物时都使用功能,则使用关键活动。

相反,你想要使用基末。

页: 1

http://api.jquery.com/keypress/

通过使用基斯特(Mkeypress)(),每当钥匙(Mouse或键盘)受到压力时,就应当检查价值,并且应当对大多数浏览器进行罚款。

Chrome问题最为突出。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签