我正在为我的公司网站创建一个回拨表单,而不是使用标准的HTML5日期选择器。我想在“Date to call”标签旁边找到他们所拥有的东西。
https://www.scottishpower.co.uk/account/click2call.process?execution=e1s1
我目前正在使用Bootstrap 2,这是我目前的输入代码段,要查看的网址是:http://temp.tefl.org.uk/callback
<div class="control-group">
<label class="control-label" for="inputEmail">Date To Call</label>
<div class="controls">
<select>
<option>Monday (date)<option>
<option>Tuesday (date)<option>
<option>Wednesday (date)<option>
<option>Thursday (date)<option>
<option>Friday (date)<option>
<select>
</div>
</div>
答案 0 :(得分:2)
您没有关闭选项元素。
尝试以下代码:
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script type="text/javascript">
$(function(){
var x = new Date().getDay();
var elem = $("div.controls select option")[x];
$(elem).prop("selected","selected");
});
</script>
<div class="control-group">
<label class="control-label" for="inputEmail">Date To Call</label>
<div class="controls">
<select>
<option>Monday (date)</option>
<option>Tuesday (date)</option>
<option>Wednesday (date)</option>
<option>Thursday (date)</option>
<option>Friday (date)</option>
<select>
</div>
</div>