答案 0 :(得分:1)
你可以这样做:
property.className = "form-control";
全:
var response = originalRequest.responseXML;
var property = document.createElement("select");
property.className = "form-control";
property.id = "predicate(" + addprop.level + "," + addprop.count + ")";
property[property.length] = new Option("Properties", "");
var options = response.getElementsByTagName('option');
有关MDN here的更多信息。
答案 1 :(得分:0)
您可以使用$('元素')来创建任何文档元素 然后使用.append(元素)将元素放到目标父元素中......如果有效,请尝试使用我的代码
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<form role="form">
<div class="form-group" id="div">
<!-- begin snippet: js hide: false -->
&#13;
<label>Select</label>
</div>
</form>
<script>
$(document).ready(function(){
var select = $('<select class="form-control"></select>');
var option = $('<option value="foo">Foo</option');
select.append(option);
$("#div").append(select);
});
</script>
</body>
</html>
答案 2 :(得分:0)
一般来说,我会创造新的东西 https://jsfiddle.net/Ljdxnwot/5/ 我写的文字
var txt="<select class'form-contro'>"+
"</select>";
答案 3 :(得分:0)
您可以使用$('element')创建任何文档元素 然后使用.append(元素)将元素放到目标父元素中......如果有效,请尝试使用我的代码
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<form role="form">
<div class="form-group" id="div">
<label>Select</label>
</div>
</form>
<script>
$(document).ready(function(){
var select = $('<select class="form-control"></select>');
var option = $('<option value="foo">Foo</option>');
select.append(option);
$("#div").append(select);
});
</script>
</body>
</html>
<label>Select</label>
</div>
</form>
<script>
$(document).ready(function(){
var select = $('<select class="form-control"></select>');
var option = $('<option value="foo">Foo</option');
select.append(option);
$("#div").append(select);
});
</script>
</body>
</html>