gpt4 book ai didi

html - 单击时更改 Bootstrap 按钮的状态

转载 作者:搜寻专家 更新时间:2023-10-31 19:29:33 25 4
gpt4 key购买 nike

我有一个时事通讯的注册表单,我已将其嵌套在模态框内。一切正常,但用户体验非常糟糕。因此,我想添加以下功能。

当有人使用姓名和电子邮件注册并单击“注册”时,我希望按钮变为红色并改为显示“关闭”。由于表格来自 mailchimp,我不能更改 <input type="submit" value="Signup" name="subscribe" id="mc-embedded-subscribe" class="button btn btn-success"></input>改为一个按钮。

这有可能吗?

这里有一个注册表单的工作演示。目前按钮在注册后变为红色,但我希望按钮改为关闭:

Demopage

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>


</head>
<body>
<div class="mk row">
<a href="#">
<div class="col-sm-12 margin_bottom">
<div class="hover11 column">
<figure>
<a href="#" data-toggle="modal" data-target="#nyhedsbrev-tilmelding">
<img src="https://dohanews.co/wp-content/uploads/2016/07/headline.png" alt="Sign up for our newsletter" class="img-responsive"></img>
</a>
</figure>
</div>
<div class="modal fade" id="nyhedsbrev-tilmelding" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div id="mc_embed_signup">


<form action="https://zalis.us17.list-manage.com/subscribe/post?u=3be651219436ee0f217f040a5&amp;id=d07c036d2e" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<h2>Subscribe to our mailing list</h2>
<div class="indicates-required"><span class="asterisk">*</span> indicates required</div>
<div class="mc-field-group">
<label for="mce-EMAIL">Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
<label for="mce-FNAME">First Name </label>
<input type="text" value="" name="FNAME" class="" id="mce-FNAME">
</div>

<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div> <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_3be651219436ee0f217f040a5_d07c036d2e" tabindex="-1" value=""></div>
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
</form>
</div>
</div>

</div>
</div>
</div>
<div class="inner-wrapper bottom-left"></div>
</div>
</a>
</div>
</body>
</html>

最佳答案

您可以添加 onclick 属性来执行您想要的人员:

 <input type="submit" value="Signup" name="subscribe" id="mc-embedded-subscribe" class="button btn btn-success" onclick="this.value='close'; this.style.backgroundColor='red';"></input>

或者使用js选择器:

<script>


let $input = document.getElementById('mc-embedded-subscribe')
$input.addEventListener('click', function (){
this.value= "close"
this.backgroundColor= "red"
})
</script>

关于html - 单击时更改 Bootstrap 按钮的状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51830774/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com