easyui textbox 得到和失去焦点不可同时生效的问题

hb_dmgy 2017-04-10 04:21:22
jQuery EasyUI 1.5.1
<input id="textbox1" class="easyui-textbox" data-options="multiline:true" value="This TextBox will allow the user to enter multiple lines of text." style="width:300px;height:30px">

$(function(){
$("#textbox1").textbox('textbox').bind("blur", function () {
$('#textbox1').textbox({
height:19
});
//$('#textbox1').textbox().next('span').find('textarea').css("height",19);
});
$("#textbox1").textbox('textbox').bind("focus", function () {
$('#textbox1').textbox({
height:60
});
//$('#textbox1').textbox().next('span').find('textarea').css("height",60);
});
});
失去焦点事件不起作用,为什么?
...全文
239 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hb198701 2017-04-14
  • 打赏
  • 举报
回复
我按照网上的几种写法都没用 如果你这个控件没有特殊的用途,不妨使用原始的 html 提供<input>标签,然后把easyui 的样式弄上去试试,我暂时使用这种方式处理的 <input type="text" name="volumnWidth" placeholder="宽" onblur="volumnblur(this);" style="border:1px solid #95B8E7;margin: 0px; padding-top: 0px; padding-bottom: 0px; height: 28px; line-height: 28px; width: 86px;">
  • 打赏
  • 举报
回复
不能重复调用$('#textbox1').textbox构造,输入框会重新生成导致绑定的事件失效,直接操作dom就行了
            $(function () {
                $("#textbox1").textbox('textbox').bind({
                    blur: function () {
                        $(this).css({ height: 19 }).parent().css({ height: 'auto' });
                    }
                     , focus: function () {
                         console.log('focus')
                         $(this).css({ height: 60 }).parent().css({ height: 'auto' });
                     }
                })
            });

87,994

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧