I’m trying to pass an argument to a function, which works fine on Chrome but not on all versions of Firefox. Here’s the code :
$('input').focus(function()
{
alert(this.width);
});
this.width appears to be undefined on some versions of FF.
Please help me.
From your description, it seems the problem has nothing to do with passing an argument to a function, it’s just that
this.widthis undefined in some browsers? I couldn’t find documentation forwidthas a property of an input element, so it doesn’t surprise me that it doesn’t work consistently.Have you tried
this.offsetWidth? Orthis.style.width?Or given that you seem to be using jQuery you might also look at
$(this).width().