次のコードを使用しています。
$('html, body').animate({ scrollTop: $($(this).attr('href')).offset().top });
Typescript から次のようなエラー メッセージが表示されます。
The property 'top' does not exist on value of type 'Object'
jQuery定義ファイルに何かが欠けていると思います。他の誰かがこの問題を見たことがありますか、それともこれは jQuery では通常使用されないものですか? それは私が前に見たことがないものです。
詳細については。これが使用されるコードは次のとおりです。
$.fn.buildTableOfContent = function () {
"use strict";
var h2 = this.find('h2');
if (h2.length > 0) {
var h1 = this.find('h1:first');
if (h1.length === 0) {
h1 = this.prepend('<h1>Help</h1>').children(':first');
}
var menu = h1.wrap('<div class="h1 with-menu"></div>')
.after('<div class="menu"><img src="/Content/images/menu-open-arrow.png" width="16" height="16"><ul></ul></div>')
.next().children('ul');
h2.each(function (i) {
this.id = 'step' + i;
menu.append('<li class="icon_down"><a href="#step' + i + '">' + $(this).html() + '</a></li>');
});
menu.find('a').click(function (event) {
event.preventDefault();
$('html, body').animate({ scrollTop: $($(this).attr('href')).offset().top });
});
}
return this;
};