我有一个按钮并将其放在浏览器的顶部.因此,当鼠标单击或鼠标悬停在此定位按钮上时,我需要显示下拉列表.
HTML
<div class="translator">
<div class="translate-btn">Translator</div>
<div class="translate-dropdown">
<select>
<option>Translate-1</option>
<option>Translate-2</option>
<option>Translate-3</option>
</select>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.translator {
position: absolute;
top: 0;
right: 10%;
z-index: 9999;
}
.translate-btn {
background-color: rgba(136, 121, 91, 0.8);
border-radius: 0 0 5px 5px;
color: #fff;
cursor: pointer;
font-size: 13px;
font-weight: bold;
padding: 4px 15px 5px;
text-align: center;
text-transform: uppercase;
}
Run Code Online (Sandbox Code Playgroud)
使用此HTML我需要在用户点击或鼠标悬停在"translate-btn"时显示"translate-dropdown"DIV.
任何人都可以告诉我是否可以使用纯CSS或者我是否需要使用jquery?
希望有人可以帮助我.谢谢.
我有一个标记<ul>如下:
<ul>
<li class=""><a href="">Insulated And Extruded</a></li>
<li class=""><a href="">Grille Type Rolling</a></li>
<li class="active2"><a href="">PVC High Speed Doors</a></li>
<li class=""><a href="">Swinging doors</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
在这里,我想检查li一个名为的类active2,如果有,那么我需要删除该类,并需要添加不同的类li.
这是我在jQuery中尝试的方式:
if($('ul li').hasClass('active2')) {
$(this).removeClass('active2').addClass('active1');
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
任何人都可以帮我解决这个问题吗?
我需要在表单中设置一个单选按钮; 必须使用来自AJAX响应的值检查它.
我的AJAX响应是response.drive."手动"或"自动"可能是它的价值.
更新: 所以我尝试了一些不同的方式,但我无法弄清楚这一点.
单程 :
if(response.drive=="Manual") {
.find('[name=drive]')[0].checked = true
} else {
.find('[name=drive]')[1].checked = true
}
Run Code Online (Sandbox Code Playgroud)
其他方式:
.find("input:radio[name='drive'][value='"+ response.drive +"']")[0].checked = true.end()
Run Code Online (Sandbox Code Playgroud)
这是我的ajax成功函数用于填充表单值的方式.
.success(function(response) {
// Populate the form fields with the data returned from server
response = jQuery.parseJSON(response)
$('#editVehicle')
.find('[name="vehicle_id"]').val(response.vehicle_id).end()
.find('[name="vehicle_name"]').val(response.vehicle).end()
.find('[name="seats"]').val(response.seats).end()
.find('[name="luggage"]').val(response.luggage).end()
.find('[name="doors"]').val(response.doors).end()
.find('[name="emission"]').val(response.emission).end()
//.find('[name="drive"]').val(response.drive).prop("checked",true).end()
//.find('[name="aircon"]').val(response.aircon).prop("checked",true).end()
//.find("input:radio[name='drive'][value='"+ response.drive +"']")[0].checked = true.end()
//if(response.drive=="Manual"){
.find('[name=drive]')[0].prop('checked').end()
//}else{
//.find('[name=drive]')[1].prop('checked')
//}
.find('[name="rental"]').val(response.price).end();
// Show the dialog
---- -
----
---
Run Code Online (Sandbox Code Playgroud)
这是单选按钮的HTML:
<div class="form-group">
<label for="">Transmission :</label>
<div class="col-sm-8"> …Run Code Online (Sandbox Code Playgroud) 我正在使用此函数创建几个月的下拉菜单。
function formMonth(){
$month = strtotime(date('Y').'-'.date('m').'-'.date('j').' - 12 months');
$end = strtotime(date('Y').'-'.date('m').'-'.date('j').' + 0 months');
while($month < $end){
$selected = (date('F', $month)==date('F'))? ' selected' :'';
echo '<option'.$selected.' value="'.date('F', $month).'">'.date('F', $month).'</option>'."\n";
$month = strtotime("+1 month", $month);
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是我需要使用 1 到 12 的数值作为选项值。
此时它使用月份名称来表示value这样的选项。
<select size="1" name="month">
<option selected value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
Run Code Online (Sandbox Code Playgroud)
谁能告诉我如何修改这个功能。谢谢。
我正在尝试创建一个受密码保护的网站.在这里我想做的是,如果用户第一次访问我的网站然后需要插入密码来访问我的网站.他们第一次输入密码时可以自由访问我的网站.
这就是我使用javascript和做的方式php:
<?php if($page == 'index'): ?>
<script language="Javascript">
//prompt.
var password;
var correctPass = "123456";
password = prompt("Enter in the password:","");
if(password == correctPass) {
alert('click OK to view this site');
} else {
window.location = "http://google.com"
}
//->
</script>
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)
这是有效但我的问题是如果用户再次进入索引页面,他们需要插入密码.
任何人都可以告诉我如何解决这个问题.谢谢.