当我知道要指定哪个元素时,我找到了这个问题的答案,但我正在寻找的方法是检查'滚动'是否有任何具有特定类的元素进入视图,并修改它们(例如,改变不透明度 - 只有那些进入视野的人).我知道代码可能看起来与此类似,但我无法使其工作:
jQuery(window).on("scroll", function() {
var difference = jQuery(window).offset().top + jQuery(window).height()/2;
if (difference > jQuery(".makeVisible").offset().top) {
jQuery(this).animate({opacity: 1.0}, 500);
}
});
Run Code Online (Sandbox Code Playgroud)
非常感谢你.注意:存在变量差异,因为我希望元素在到达屏幕中间时变得可见.
我在页面上创建了一个按钮,其HTML如下所示:

现在在我的JavaScript中我有一个jQuery,它找到这样的按钮:
$('.personlistbtn').click(function(e) {
console.log("inside click event of person list");
console.log("provider id was this " + provider_id);
// ?????
});
Run Code Online (Sandbox Code Playgroud)
我想将一些参数附加到我上面发布的href按钮,这样它就可以转到我的Rails应用程序中的新页面,其中包含我传递给它的那些参数,所以希望这样的东西:
<a href="/pharmacy/patients?provider_id=234" >
Run Code Online (Sandbox Code Playgroud)
注意我附上了?provider_id = 234.我怎样才能做到这一点?
我有这个链接:
<a id="Link" href="mailto:bestellung@i-drain.net?subject=I-Drain Bestellung&body="></a>
Run Code Online (Sandbox Code Playgroud)
现在,我想在&body =“之后附加来自表单元素的数据
因此,例如,第一次更改为&body="New text,下次更改为
&body="New text , Another text。
我怎样才能做到这一点?无法正常工作..谢谢:)