输入框获得焦点与失去焦点、阴影效果
2015-04-01 11:10
381 查看
1.jQuery表单Input文本框默认说明文字获得焦点后消失效果
第一种方法:
<script>
$(function(){
$('#input').focus(function(){
$(this).val("");
});
$('#input').blur(function(){
$(this).val("请输入反馈意见");
});
})
</script>
第二种方法:
(通用)
$(function() {
$('input:text').each(function() {
var txt = $(this).val();
$(this).focus(function() {
if (txt === $(this).val()) {
$(this).val("");
}
});
$(this).blur(function() {
if ($(this).val() == "") {
$(this).val(txt);
}
});
});
})
第三种方法:
效果:鼠标点击输入框时,提示性文字无。
<input type="text" value="请输入反馈意见" name="input" id="input" onfocus="if(value=='请输入反馈意见') {value=''}" onblur="if (value=='') {value='请输入反馈意见'}"/>
效果:鼠标点击输入框后,文字颜色变为黑色。
<script>
$(function() {
$('#input').focus(function() {
document.getElementById("input").style.color="#000";
});
})
</script>
输入框box-shadow活的焦点时有阴影
<style>
.test{
display: block;
width: 100%;
height: 34px;
font-size: 14px;
line-height: 1.42857143;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
-webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s
}
.test:focus {
border-color: #66afe9;
outline: 0;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6)
}
</style>
<input type="text" value="请输入内容" class="test"/>
第一种方法:
<script>
$(function(){
$('#input').focus(function(){
$(this).val("");
});
$('#input').blur(function(){
$(this).val("请输入反馈意见");
});
})
</script>
第二种方法:
(通用)
$(function() {
$('input:text').each(function() {
var txt = $(this).val();
$(this).focus(function() {
if (txt === $(this).val()) {
$(this).val("");
}
});
$(this).blur(function() {
if ($(this).val() == "") {
$(this).val(txt);
}
});
});
})
第三种方法:
效果:鼠标点击输入框时,提示性文字无。
<input type="text" value="请输入反馈意见" name="input" id="input" onfocus="if(value=='请输入反馈意见') {value=''}" onblur="if (value=='') {value='请输入反馈意见'}"/>
效果:鼠标点击输入框后,文字颜色变为黑色。
<script>
$(function() {
$('#input').focus(function() {
document.getElementById("input").style.color="#000";
});
})
</script>
输入框box-shadow活的焦点时有阴影
<style>
.test{
display: block;
width: 100%;
height: 34px;
font-size: 14px;
line-height: 1.42857143;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
-webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s
}
.test:focus {
border-color: #66afe9;
outline: 0;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6)
}
</style>
<input type="text" value="请输入内容" class="test"/>
相关文章推荐
- jQuery表单获取和失去焦点输入框提示效果的实例代码
- input 输入框获得/失去焦点时隐藏/显示文字(jquery版)
- JavaScript基础 表单内的text文本输入框 获得焦点onfocus 失去焦点onblur
- [Javascript]如何在HTML中实现点击input输入框(获得焦点)后默认提示消失的效果
- js控制输入框获得和失去焦点时状态显示的方法
- 鼠标滑入滑出,输入框获得失去焦点后触发事件的N种方法之一二
- JavaScript基础 表单内的text文本输入框 获得焦点onfocus 失去焦点onblur
- jQuery表单获取和失去焦点输入框提示效果
- input 输入框获得/失去焦点时隐藏/显示文字
- input 输入框获得/失去焦点时隐藏/显示文字(jquery版)
- input 输入框获得/失去焦点时隐藏/显示文字(jquery版)
- 通过自定义属性存储数据实现输入框获得焦点与失去焦点改变value值
- Jquery输入框获得/失去焦点方式
- 输入框的提示信息(获得焦点和失去焦点时显示提示信息)
- jQuery表单获取和失去焦点输入框提示效果的实例代码
- 输入框获得焦点和失去焦点
- input 输入框获得/失去焦点时隐藏/显示文字
- js控制输入框获得和失去焦点时状态显示的方法
- input 输入框获得/失去焦点时隐藏/显示文字
- 利用StateListDrawable当EditText获得,失去焦点时分别设置其内容的不同颜色