3

Calling JavaScript functions in jQuery functions?

 2 years ago
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.
neoserver,ios ssh client

Calling JavaScript functions in jQuery functions?

advertisements

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?

I'm creating silverlight without Visual Studio. I just have raw html, XAML, and js (javascript). What I want to do is pass values from the XAML to the javascript. I can call and activate javascript functions from XAML. See below. The canvas element h

How to call javascript from the Jquery function?

I want to call jquery function in side of java script. My code is: <script type="text/javascript"> function calljs(){ getUserMail(usermMail); } $(function() { function getUserMail(usermMail) { ***some code***** } }); </script> I got

Changing the call javascript function variable with jquery?

There is a html page like this: <div id="list"><a onclick = "javascript:addplaylist('shv231a','1');" href="javascript:void(0);">+</a></div> <div id="list"><a onclick = "javascri

Detect movements on mobile phones to call javascript functions

I have a website that I would like to be able to also play in mobiles. In the interface I mostly use javascript. How can I detect the moves of the user's fingers on the screen , so I can call the right javascript functions? For example , in my photog

How can I use a javascript function to create polymer elements that can call javascript functions

I have an array of objects, each of which I want to render into polymer cord-card element. Each element when tapped, i'd like to call a javascript function. I've used a simple loop to create the elements with javascript however nothing happens when I

Calling Javascript functions from a Java applet

I have a Java Applet in a HTML page. I need to have the applet call a certain Javascript function to notify the HTML page of certain events. The way I call the JavaScript function currently is: getAppletContext().showDocument(new URL("javascript:wind

WPF - Error when calling javascript function - Unknown name. (HRESULT exception: 0x80020006 (DISP_E_UNKNOWNNAME))

I am new to wpf. I am using "WebBroswer" in my wpf application to render Google map. So I am calling Pan(x, y) JavaScript method with some parameters form my c# code. But I am getting this below error. Unknown name. (Exception from HRESULT: 0x80

Means of calling JavaScript functions

How can I call a JavaScript function when a div's display is set to none? This is the code I have : if(document.getElementById("myDiv").style.display == "none"){ myFunction(); } I was thinking having a function that repeats everytime (

How do some html buttons in websites, do things without calling JavaScript functions?

In this dictionary web site, there is an HTML button labeled "Translate" which translates the word inside the textbox into Sinhala language. The translate button doesn't call a function which exists within the scoop, but the translation is perfo

call javascript functions without receiver

Let's say we have a function: function fn(){return this;} If we call the function by foo = fn();, then foo will get the value of this, but I am curious about where the return goes if the the function is called without receiver, i.e. fn();? Thanks!It

[Solved] Call javascript function from asp Textbox

I have seen some post regarding this question but i cannot find a solution for my problem. I have a text box and through autocompleteextender i am searching records from database. which works fine. <ajaxToolkit:ToolkitScriptManager ID="ToolkitScri

How to call JavaScript functions from Rails views?

I have JavaScript functions which popup the new screen and I need to use them in a Rails view. This is the script in /app/assets/signup.js: <script type="text/javascript"> function popup() { cuteLittleWindow = window.open("signup.html

how to call javascript variables in jQuery?

I basically made a program that generates random ball numbers based on how many balls the user wants to display on the screen and then the user has to type in the ball numbers in order and if he guesses it right, he wins or else he loses. However, jQ

Call - Javascript function

Any one help me. I have described the problem in the following lines. I want to call the second.html with in one.html. Inside the second.html ,I have included the second.js using script tag. When I call the second.html in the browser(safari,chorme,fi

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK