我有两个表单字段。如果点击<div class="offer-text"> RS.750/- </div>
中的文字,RS.750/-
可能会出现在按钮中。因为我是初学者。任何人都可以帮我这样做吗?
<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>
答案 0 :(得分:1)
要将值发送到表单按钮,请使用以下代码:
$(".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"))
})
&#13;
<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">
&#13;