Calling JavaScript functions in jQuery functions?
source link: https://www.codesd.com/item/calling-javascript-functions-in-jquery-functions.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Calling JavaScript functions in jQuery functions?
I have two JavaScript functions that I want to call from inside of a jQuery function. Because I load images dynamically, I want to check the width of each image by calling the two functions func1()
and func2()
that will check the width.
If width < 20px then double width
I don't want to wait for the images to fully load then do the check.
I tried this but didn't work
$(document).ready(function ()
{
$('img').each(function()
{
....
})
func1();
func2();
})
function func1()
{
....
}
function func2()
{
....
}
What am I missing?
Unless the img tags have the width specified you will not be able to correctly get the width before it is completely loaded. The browser has no way of knowing what are the dimensions until it has the entire image.
Here is a way to wait until the images are loaded:
Official way to ask jQuery wait for all images to load before executing something
Related Articles
How can I call javascript functions and pass values from XAML / Silverlight?
How to call javascript from the Jquery function?
Changing the call javascript function variable with jquery?
Detect movements on mobile phones to call javascript functions
How can I use a javascript function to create polymer elements that can call javascript functions
Calling Javascript functions from a Java applet
WPF - Error when calling javascript function - Unknown name. (HRESULT exception: 0x80020006 (DISP_E_UNKNOWNNAME))
Means of calling JavaScript functions
How do some html buttons in websites, do things without calling JavaScript functions?
call javascript functions without receiver
[Solved] Call javascript function from asp Textbox
How to call JavaScript functions from Rails views?
how to call javascript variables in jQuery?
Call - Javascript function
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK