【问题标题】:Contact form inputs fade out and fade in [closed]联系表格输入淡出和淡入[关闭]
【发布时间】:2019-07-08 07:19:32
【问题描述】:

您好,我正在创建有四个输入的联系表单,当我单击单个输入时我想要的名称、电话、电子邮件、消息然后另一个将淡出 30%,如电子邮件、电话、消息,如果我单击另一个然后另一个一个会褪色 30%,如果我填充了输入,则输入看起来不会褪色。

<div class="contact-form ss-map">
                        <h1>Message</h1>
                        <form action="" method="post" id="validateForm">
                            <div class="form-group error">
                                <input type="text" name="name" id="name" class="form-control" placeholder="Name" required="" area-required="true">
                            </div>
                            <div class="form-group">
                                <input type="text" name="email" id="email" class="form-control" placeholder="Email" required="" area-required="true">
                            </div>
                            <div class="form-group">
                                <input type="text" name="phone" id="phone" class="form-control" placeholder="Phone" required="" area-required="true">
                            </div>
                            <div class="form-group">
                                <input type="text" name="message" id="message" class="form-control" placeholder="Message" required="" area-required="true">
                            </div>
                            <div class="form-group">
                                <a href="#" class="link link-green center submit-btn"><span>Start the conversation</span></a>
                                <!-- <input type="submit" name="submit" value="Start the conversation"> -->
                            </div>
                        </form>
                        <p class="copyright d-none d-sm-block">Copyright @ 2018 JGM</p>
                    </div>

【问题讨论】:

标签: javascript php jquery wordpress


【解决方案1】:

对于这个问题,您可以将 CSS :focus 选择器与 :not 选择器组合使用。

如果您想要示例代码,请发表评论。

【讨论】:

  • 您好,我正在创建联系人表单,其中包含四个输入名称、电话、电子邮件、消息,当我单击单个输入时,另一个输入将淡出 30%,如电子邮件、电话、消息,如果我单击另一个,然后另一个将褪色 30%,如果我填充了输入,则输入看起来没有褪色。
  • 我正在添加该脚本,但仍然存在一些问题,当单击输入字段时它应该是不透明度 1
【解决方案2】:

这里。

将点击输入的opacity 设置为 1,其他设置为 0.7(淡化 30%)。

$(".fade-others-on-click").click(function(){
  $(this).css('opacity', '1')
  $(".fade-others-on-click").not($(this)).css('opacity', '0.7')
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input class="fade-others-on-click">
<input class="fade-others-on-click">
<input class="fade-others-on-click">
<input class="fade-others-on-click">

【讨论】:

  • 如果我选择另一个,那么另一个将是不透明度 1 并且所有输入褪色 30%?
  • 您选择的不透明度为 1,其他输入(在同一类中,如本示例所示)将是透明的,不透明度为 0.7,我认为您的“淡化 30”可以接受%”。你可以运行代码 sn -p 看看它是否真的是你想要的。
  • 它工作正常,但如果我点击正文块,它应该显示与 1 相同的不透明度
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多