+ 1
Calling jQuery function from "normal" JavaScript
Hello everyone, could you anyone help me with my rpblem please? I would like to call jquery function from JS (and additionally pass JS variables to jQuery). Here is my sample code: <script> $(document).ready(function() { function print(num) { alert(num); } }); var something = 10; print(something); </script> Thanks a lot for help :)
6 Answers
+ 1
If your question is simply if you can mix jQuery and JavaScript together, then yes you can.
+ 3
What problem are you running in to?
Btw, throw your var/print stuff at the bottom inside of the .ready(). If not, it'll try to run the function before you even defined the function.
$(function() {
function printIt(num)
{
alert(num);
}
var something = 10;
printIt(something);
});
https://code.sololearn.com/WSFxQ6nk39Eq/#js
+ 1
Hello, thanks for fast reply. In my real website, I have a html5 video player with JS function (onended action in video tag). This function plays another video by changing video src and I also need this function to run jQuery to run php file command.
Would it work like this?
Thanks for reply
Radek :)
+ 1
Should I post my real code here, so you can better understand?
My explanation may be a bit confusing, English isn't my first language.
+ 1
$ function
+ 1
$ function