[jQuery] call a method outside a jquery object
Hello Everybody,
I am not sure I have explained well enought what I mean.
I found very difficult to call a method outside his scope.
For example I have 2 files js
myFunction.js
init.js (where I initialize all my page)
[init.js ]
// JavaScript Document
$(document).ready(function(){
//call getX();
});
-----------------------------------------------------
[myFunction.js ]
// JavaScript Document
$(
function(){
var x = "Hello world";
function getX(){
alert(x);
}
}
);
I tried many syntax in order to call the method outside its scope
$.getX();
$(function(){getX()});
$().function().getX();
$("myHtmlObj").click(function(){getX()});
I really would like to understand that issue, if you also may suggest
the title of a good book and the chapter that explain it I would
really appreciate.
Many thanks
- jasper