首页 新闻 会员 周边

论坛回复功能,编辑器里@name后光标定位问题

0
悬赏园豆:10 [待解决问题]

单击回复按钮后 光标在@name的前面  请问怎样才能让光标在@name后面

js代码

$('.request-reply').on('click', function () {
        var othis = $(this),
            type = othis.attr('type');
        $('.layui-form .quotepid').val(othis.attr('pid'));
        var val = $(window.frames["LAY_layedit_1"].document).find('body').val();
        var aite = '@' + othis.attr('username').replace(/\s/g, '');
 
         $(window.frames["LAY_layedit_1"].document).find('body').focus()
         $(window.frames["LAY_layedit_1"].document).find('body').append(aite+' ' + val);
         if(val.indexOf(aite) !== -1) return;
         $(window.frames["LAY_layedit_1"].document).find('body').val(aite +' ' + val);

       
    });
  

问题图片:

ycyzharry的主页 ycyzharry | 高人七级 | 园豆:25653
提问于:2018-05-09 15:35
< >
分享
所有回答(1)
0

不知道有没有用?https://blog.csdn.net/gyq04551/article/details/80175326

不知道直接找到表情所在dom元素然后定位是否可行?

hehe_54321 | 园豆:750 (小虾三级) | 2018-05-10 21:08

我看的是这个帖子 

layedit编辑器如何设置光标位置

但是不知道el, iframeDOM 要传什么值

支持(0) 反对(0) ycyzharry | 园豆:25653 (高人七级) | 2018-05-11 11:01
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册