文本框的改变用change事件

  要用bind,两个是有区别的,change只是在失去焦点的时候出发,很多时候不能满足需要。

 代码如下  

$('#flowfromid').bind("propertychange",function(){

//你的内容

});

  文本框回车事件

 代码如下  

$(document).ready(function () {
$("#txt_JumpPager").keydown(function (e) {
var curKey = e.which;
if (curKey == 13) {
$("#lbtn_JumpPager").click();
return false;
}
});
});

  补充还有一些像

  $("#txtEmail").trigger("focus"); //默认时文本框获得焦点

  $("#txtEmail").focus(function () { //文本框获取焦点事件

  都是非常好用的

 代码如下  

<input ></textarea>
例子

<script type="text/javascript">
    $(function(){
        $(":input").focus(function(){
              $(this).addClass("focus");
        }).blur(function(){
              $(this).removeClass("focus");
        });
    })
</script>

  用:input匹配所有的input元素,当获取焦点时,就添加样式focus,通过$(this)自动识别当前的元素。focus()方法是获取焦点事件发生时执行的函数。blur()方法是失去焦点事件发生时执行的函数。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2022-01-20
  • 2022-12-23
  • 2022-02-16
相关资源
相似解决方案