【发布时间】:2021-10-17 00:59:16
【问题描述】:
我是一名学习 JavaScript 的学生。我想把strong标签里的checkValue值放到输入框里,但是不知道怎么写JavaScript才能把它放到输入框里。我需要找到 div 的 cart_table 吗?还是我应该找到一个强标签?
<script>
$().ready(function() {
$("#optionSelect").change(function() {
var checkValue = $("#optionSelect").val();
var checkText = $("#optionSelect option:selected").text();
var product = $("#productname").text();
var price = parseInt($("#price").text());
var test = parseInt($(this).find(':selected').data('price'));
var hapgae = price + test
if (checkValue != "no") {
var whtml =
" <div class=\"cart_table\">\n" +
" <hr style='width: 300px; margin-bottom: 30px;'>" +
" <p style='font-size: 17px;'>" + product + "</p>" +
" <p style='font-size: 13px; margin-top: -10px; class=\"check\" margin-bottom: 20px;'>" + checkText + "</p>" +
" <strong class=\"value_code2\">" + checkValue + "</strong>\n" +
" <input name=\"value_code\" id=\"value_code\" class=\"value_code\">" +
强标签和输入标签参考此部分。
" <strong class=\"value_code2\">" + checkValue + "</strong>\n" +
" <input name=\"value_code\" id=\"value_code\" class=\"value_code\">" +
【问题讨论】:
标签: javascript django django-templates