需要帮助将此JavaScript代码应用于我的现有代码吗
我几乎完成了一个简单的音乐切换按钮,我一直在工作,并希望它淡入我的网页一样,滚动到顶部按钮在我的网站() 我设法从scroll to top按钮获取javascript,如下所示:需要帮助将此JavaScript代码应用于我的现有代码吗,javascript,html,Javascript,Html,我几乎完成了一个简单的音乐切换按钮,我一直在工作,并希望它淡入我的网页一样,滚动到顶部按钮在我的网站() 我设法从scroll to top按钮获取javascript,如下所示: var start = { setting: { startline: 100, scrollto: 0, scrollduration: 1e3, fadeduration: [500, 100] }, controlHTML: '<img src=".../noa
var start = {
setting: {
startline: 100,
scrollto: 0,
scrollduration: 1e3,
fadeduration: [500, 100]
},
controlHTML: '<img src=".../noaudio.png"/>',
},
state: {
isvisible: !1,
shouldvisible: !1
},
scrollup: function() {
this.cssfixedsupport || this.$control.css({
opacity: 0
});
var t = isNaN(this.setting.scrollto) ? this.setting.scrollto : parseInt(this.setting.scrollto);
t = "string" == typeof t && 1 == jQuery("#" + t).length ? jQuery("#" + t).offset().top : 0, this.$body.animate({
scrollTop: t
}, this.setting.scrollduration)
},
keepfixed: function() {
var t = jQuery(window),
o = t.scrollLeft() + t.width() - this.$control.width() - this.controlattrs.offsetx,
s = t.scrollTop() + t.height() - this.$control.height() - this.controlattrs.offsety;
this.$control.css({
left: o + "px",
top: s + "px"
})
},
togglecontrol: function() {
var t = jQuery(window).scrollTop();
this.cssfixedsupport || this.keepfixed(), this.state.shouldvisible = t >= this.setting.startline ? !0 : !1, this.state.shouldvisible && !this.state.isvisible ? (this.$control.stop().animate({
opacity: 1
}, this.setting.fadeduration[0]), this.state.isvisible = !0) : 0 == this.state.shouldvisible && this.state.isvisible && (this.$control.stop().animate({
opacity: 0
}, this.setting.fadeduration[1]), this.state.isvisible = !1)
},
init: function() {
jQuery(document).ready(function(t) {
var开始={
设置:{
斯达林:100,
滚动至:0,
滚动持续时间:1e3,
衰减:[500100]
},
controlHTML:“”,
},
声明:{
isvisible:!1,
应可见:!1
},
scrollup:function(){
this.cssfixedsupport | | this.$control.css({
不透明度:0
});
var t=isNaN(this.setting.scrollto)?this.setting.scrollto:parseInt(this.setting.scrollto);
t=“string”==typeof t&&1==jQuery(“#”+t).length?jQuery(“#”+t).offset().top:0,this.$body.animate({
滚动顶部:t
},this.setting.scrollduration)
},
keepfixed:function(){
var t=jQuery(窗口),
o=t.scrollLeft()+t.width()-此.$control.width()-此.controlattrs.offsetx,
s=t.scrollTop()+t.height()-this.$control.height()-this.controlattrs.offsety;
这是$control.css({
左:o+“px”,
顶部:s+“px”
})
},
togglecontrol:函数(){
var t=jQuery(window.scrollTop();
this.cssfixedsupport | | this.keepfixed(),this.state.shouldvisible=t>=this.setting.startline?!0:!1,this.state.shouldvisible&!this.state.isvisible?(this.$control.stop().animate)({
不透明度:1
},this.setting.fadeduration[0]),this.state.isvisible=!0):0==this.state.shouldvisible&&this.state.isvisible&&this.control.stop().animate({
不透明度:0
},this.setting.fadeduration[1]),this.state.isvisible=!1)
},
init:function(){
jQuery(文档).ready(函数(t){
我曾尝试将其更改为我添加的新按钮,但迄今为止运气不佳。[以下是我迄今为止得到的。][2]
那么,我如何才能使新按钮像我网站上的按钮一样淡入?有没有办法用我上面链接的代码来做到这一点
谢谢
还有,很抱歉有任何错误。我仍然不擅长编码。
试试看。我现在正在做类似的事情。这是jQuery代码:
var amountScrolled = 300;
$(window).scroll(function() {
if ( $(window).scrollTop() > amountScrolled ) {
$('.fadebutton').fadeIn('slow');
} else {
$('.fadebutton').fadeOut('slow');
}
});
init
的其余部分在哪里?