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.width
is undefined in some browsers? I couldn't find documentation for width
as a property of an input element, so it doesn't surprise me that it doesn't work consistently.
Have you tried this.offsetWidth
? Or this.style.width
?
Or given that you seem to be using jQuery you might also look at $(this).width()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.