2011-04-28 86 views
0

我正在开发使用jquerymobile alpha 4.1的示例应用程序。在我的设计中,当enduser更改控件的值时,我必须从文本框中获取值。jquerymobile textBox - onChange事件 - 在Operamobile浏览器中不起作用

所以我使用下面的代码。

HTML:

<input type="text" id="username" > </input> 

JS:

$("#username").live("change" , function() { 
    alert("hai"+ $("username").val()); 
}); 

它在iphone,Safari浏览器,Android的,blackberrry原生浏览器工作正常。

,但它不会在Operamobile- 11 Operamobile 10工作(它无法检测到这一事件。)

请分享您的建议。我应该使用其他事件来避免这个错误吗?

谢谢。

回答

2

Live Example

试试这个:

$("#username").live("change" , function() { 
    alert("hai "+ $("#username").val()); 
}); 

,而不是这样的:

$("username").live("change" , function() { 
    alert("hai"+ $("username").val()); 
}); 

替代方法:(不活的()):Example

$("#username").change(function() { 
    alert("hai "+ $("#username").val()); 
}); 
+0

感谢菲尔。但它在operamobile 10和11浏览器中不起作用。其他浏览器在这种机制中工作正常。 – Finder 2011-05-02 03:27:07

+0

@Girija你解决了这个问题吗?我有同样的问题Opera Mobile 10不会触发onchange事件吗? – 2013-06-10 12:57:32

相关问题