jQuery


Link: https://bugzilla.mozilla.org/show_bug.cgi?id=167801
Look at comment 112.

copied and pasted from the link

I’ve had this problem in FF3 but this time not related to iframe or overflow
setting but because of disabling input for a moment.

If someone stumbles upon same issue, this may help:

Testcase to reproduce problem:
textarea.disabled = true;
setTimeout(function() {
textarea.disabled = false;
textarea.focus();
}, 0);

How to fix it:

textarea.blur(); // blur first
textarea.disabled = true;
setTimeout(function() {
textarea.disabled = false;
textarea.focus();
}, 0);

Advertisements

I want to fill <input type=”text” size=”20″ class=”username”/> with whatever I write in <input type=”text” size=”20″ class=”email”/> unless I write ‘@’. If I write ‘@’ in <input type=”text” size=”20″ class=”email”/> then <input type=”text” size=”20″ class=”username”/> will stop writing text.

<input type=”text” size=”20″ class=”email”/>

<input type=”text” size=”20″ class=”username”/>

with jQuery we can do it simply


jQuery('.email').keyup(function (e) {
var index = text.indexOf('@');
if (index == -1) {
jQuery('.username').val(text);
}else if (index) {
jQuery('.username').val(text.substring(0, index));
}
});