使用jQuery设置Bootstrap输入组的内容可以通过以下步骤实现:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<div class="input-group">
<input type="text" class="form-control" id="myInput" placeholder="输入内容">
<div class="input-group-append">
<button class="btn btn-primary" type="button" id="myButton">设置内容</button>
</div>
</div>
val()
方法设置其内容。在按钮的点击事件中添加以下代码:$(document).ready(function() {
$("#myButton").click(function() {
var inputValue = "新的内容"; // 替换为你想要设置的内容
$("#myInput").val(inputValue);
});
});
这样,当按钮被点击时,输入组的内容将被设置为指定的值。
关于Bootstrap输入组的更多信息,你可以参考腾讯云的相关产品文档:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>联想控股</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="http://code.jquery.com/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/bootstrap-responsiv.css">
<link rel="stylesheet" type="text/css" href="http://sandbox.runjs.cn/uploads/rs/238/n8vhm36h/dataTables.bootstra.css">
</head>
<body>
领取专属 10元无门槛券
手把手带您无忧上云