使用 Javascript 淡入/淡出
Use Javascript to fade in/fade out
我有一些JavaScript代码,在单击两个按钮之一时应用了display:none
和display:inline
的css样式,但我似乎无法让它们很好地淡入淡出,即时显示无/内联有点刺眼。
//<![CDATA[
var submitcount42059 = 0;
function checkWholeForm42059(theForm) {
var why = "";
if (theForm.FirstName)
why += isEmpty(theForm.FirstName.value, "First Name");
if (theForm.LastName)
why += isEmpty(theForm.LastName.value, "Last Name");
if (theForm.EmailAddress)
why += checkEmail(theForm.EmailAddress.value);
if (!theForm.PaymentMethodType || getRadioSelected(theForm.PaymentMethodType) == 1) {
if (theForm.CardName)
why += isEmpty(theForm.CardName.value, "Name on Card");
if (theForm.CardNumber)
why += isNumeric(theForm.CardNumber.value, "Card Number");
if (theForm.Amount)
why += isCurrency(theForm.Amount.value, "Amount");
}
if (theForm.PaymentMethodType)
why += checkSelected(theForm.PaymentMethodType, "Payment Method");
if(why != "")
{
alert(why);
return false;
}
if(submitcount42059 == 0)
{
submitcount42059++;
theForm.submit();
return false;
}
else
{
alert("Form submission is in progress.");
return false;
}
}
// Credit Card info is not required if paying by PayPal, Hosted Credit Card, COD etc
function ShowCCFields(val) {
if (!document.getElementById('paymentdiv'))
return;
if (val != 1)
document.getElementById('paymentdiv').style.display = 'none';
else
document.getElementById('paymentdiv').style.display = 'inline';
}
//]]>
<div id="paymentdiv">
<div class="col-md-4">
<div class="form-group">
<label>Card Number<sup>*</sup></label><br />
<input class="form-control dark" id="CardNumber" type="text" pattern="[0-9]*" name="CardNumber" />
</div>
</div>
</div>
<div class="col-xs-12 col-md-6">
<label class="PayCC"><input class="PaymentMethodType" onclick="ShowCCFields(this.value);" type="radio" value="1" name="PaymentMethodType" />
<span>Credit Card</span>
</label>
</div>
<div class="col-xs-12 col-md-6">
<!--<label class="PayCC"><input class="PaymentMethodType" onclick="ShowCCFields(this.value);" type="radio" value="3" name="PaymentMethodType" /><span>COD (Cash on Delivery)</span></label><br>-->
<label class="PayCC"><input class="btn btn-primary" onclick="ShowCCFields(this.value);" type="radio" value="5" name="PaymentMethodType" />
<span>PayPal</span>
</label>
</div>
我不知道
你是否愿意查看其他库,但d3.transition似乎是你正在寻找的。
一个很好的描述性引用,它将涉及什么
D3 的 selection.transition 方法使得在更改 DOM 时可以轻松地对过渡进行动画处理。例如,要将文本颜色立即更改为红色,您可以选择 body 元素并设置颜色样式:
d3.select("body").style("color", "red");
要改为对随时间变化的更改进行动画处理,请派生一个过渡:
d3.select("body").transition().style("color", "red");
这是一个很好的互动教程,我学到了关于 d3 转换的教程
相关文章:
- Javascript将图像src更改为淡入淡出
- css(或jQuery)悬停时淡入淡出
- 将淡入淡出添加到“我的身体背景滑块”
- 多重潜水淡入淡出打开
- 添加/删除类淡入淡出不起作用
- 带有计数器、缩略图、进度条和淡入淡出效果的简单jQuery幻灯片
- 使用jquery淡入淡出
- 淡入淡出脚本不起作用
- 具有淡入淡出效果的全背景图像
- 纯 JavaScript 淡入淡出 - 淡入不起作用
- 帧淡出/淡入
- 如何在onClick事件中使用ReactJS淡出/淡入内容
- 淡出 ->淡入无法正常工作
- JQuery 淡出/淡入以创建排序列表
- 无法让元素淡出/淡入
- 正在添加'淡出/淡入'响应媒体查询
- jQuery:具有淡入和淡出(淡入)的图像
- Div won't淡出/淡入
- 淡出/淡入和上卷jquery效果
- 如何根据 SELECT 更改淡出/淡入视图