我想通过文字来取代<input text...> 详情如截图。。。
请高手指点。。。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<form action="lol.php" method="POST">
<div id="input_div">
<input type="radio" name="price" value="10" >$10<br>
<input type="radio" name="price" value="20" checked>$20<br>
<input type="radio" name="price" value="30">$30<br><br>
price$<input type="text" id="it" value=""><br><br>
quantity<button type="button" id="moins" onclick="minus()">-</button>
<input type="number" name="quantity" value="1" id="count">
<button type="button" id="moins" onclick="plus()">+</button><br><br>
Total <input type="text" value="" name="sub_total" id="total">
</div>
<button type="submit">GOGOGO</button>
</form>
<script>
$(document).ready(function() {
$('#it').val($('input[checked]').val());
$('#total').val($('input[checked]').val());
$('input[type=radio]').click(function() {
$('#it').val(this.value);
$('#total').val($('#it').val()* count);
});
});
var price = document.getElementById('it');
var count = 1;
var total =0;
var countEl = document.getElementById("count");
var countEl1 = document.getElementById("total");
function plus(){
count++;
total=price.value*count;
countEl.value = count;
countEl1.value = total;
}
function minus(){
if (count > 1) {
count--;
total=price.value*count;
countEl.value = count;
countEl1.value = total;
}
}
</script>
</body>
</html>
你要先确认你的哪些input 是否确实不再需要进行直接输入,如果不需要,其实最简单的方法是定义相应的input类型样式,禁用可编辑属性(只读),并使得显示像直接输出而已。
另在样式style.css文件中添加