将jQuery函数附加到某些文本框 [英] Attaching a jquery function to some textboxes

查看:96
本文介绍了将jQuery函数附加到某些文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是jquery的新手,需要一点帮助.我创建了以下功能,该功能可以实现我想要的功能,但是当我选择一个文本框时,会自动选择其他所有文本框.如何更改它并从文本框中传递参数,以便只有选定的文本框css会在焦点和模糊上发生变化?

I am a newbie to jquery and need a little help. I have created the below function which does what I want it to however when I select a textbox every other textbox are automatically selected. How do I change it and pass a parameter from the textbox so only the selected textboxes css changes on focus and blur?

   <script language="javascript" type="text/javascript">
   $(function () {
       $('.myTextBox').focus(function () {

           $('.box.textbox').addClass("active");
       }).blur(function () {
           $('.box.textbox').removeClass("active");
       });
   });
</script>

推荐答案

您要更新触发事件的对象,请尝试;

You want to update the object that fired the event so try;

  $(function () {
       $('.myTextBox').focus(function () {
           $(this).addClass("active");
       }).blur(function () {
           $(this).removeClass("active");
       });
   });

这篇关于将jQuery函数附加到某些文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆