gpt4 book ai didi

javascript - Bootstrap : how to pass text value to button?

转载 作者:行者123 更新时间:2023-12-03 03:07:02 25 4
gpt4 key购买 nike

我有两个表单字段。如果单击 <div class="offer-text"> RS.750/- </div> 中的文本RS.750/-可以出现在按钮中。因为我是 Bootstrap 新手。谁能帮我做到这一点?

<div class="col-sm-12">
<div class="col-sm-3"></div>
<div class="col-sm-6">
<form method="POST" action="information.php">
<div class="">
<button type="submit" name="submit" class="button button-block"/>SEND</button>
</div>
</form>
</div>
<div class="col-sm-3"></div>
</div>

<div class="col-sm-12">
<div class="col-sm-3"></div>
<div class="col-sm-6">
<div class="form2">
<div class="row">
<div class="column">
<div class="offer-text"> RS.750/- </div>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-3"></div>

最佳答案

要将值发送到表单按钮,请使用以下代码:

$(".offer-text").click(function() {
$("form button[type=submit]").text($(this).text())
})

演示

$(".offer-text").click(function() {
$("form button[type=submit]").text($(this).text())
})

$("img").click(function() {
$("form button[type=submit]").text($(this).attr("value"))
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-sm-12">
<div class="col-sm-3"></div>
<div class="col-sm-6">
<form method="POST" action="information.php">
<div class="">
<button type="submit" name="submit" class="button button-block" />SEND</button>
</div>
</form>
</div>
<div class="col-sm-3">
</div>
</div>


<div class="col-sm-12">
<div class="col-sm-3"> </div>
<div class="col-sm-6">
<div class="form2">
<div class="row">
<div class="column">
<div class="offer-text"> RS.750/- </div>

</div>
</div>
</div>
</div>
<div class="col-sm-3"></div>
</div>

<img src="img/Sar Utha Kay Jeo.png" alt="IMG" style="width:100%" value="RS.1750/-" class="hover-shadow cursor">

关于javascript - Bootstrap : how to pass text value to button?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47121845/

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