I am trying to determine the position and height / width of a DOM element through TypeScript / JQuery. Before TypeScript, I just did something like this:
function ActOnClick(itemClicked, loadPath) {
var v1 = itemClicked.offset();
var v2 = itemClicked.width();
var v3 = itemClicked.height();
};
$(document).ready(function () {
$("#idCRM").click(function () {
ActOnClick($("#idCRM"), "/Widgets/GetCRM");
});
}
where idCRM is the "section" in my cshtml document (but it can be any div, etc.)
Now I'm trying to move this code to TypeScript, but what type do I expect in the ActOnClick function of jQuery $ ("# idCRM")? Right now I’m choosing “Element”, but a) it doesn’t reveal width, height, etc. And b) the call to ActOnClick is not executed due to $ ("# idCRM")!
function ActOnClick(itemClicked: Element, loadPath: string) {
var v1 = itemClicked.offset(); <-- FAILS
var v2 = itemClicked.width(); <-- FAILS
var v3 = itemClicked.height(); <-- FAILS
};
$(document).ready(function () {
$("#idCRM").click(function () {
ActOnClick($("#idCRM"), "/Widgets/GetCRM"); <-- FAILS
});
}
source
share