No possibility to select text inside <input> when parent is draggable

后端 未结 4 1475
野趣味
野趣味 2021-01-17 10:59

This one is IE specific (not anymore, apparently). We have very simple code:

Text

4条回答
  •  有刺的猬
    2021-01-17 11:36

    The way Ben McCormick mentioned works good for me on the major browsers (tested with Internet Explorer 11, Firefox and Chrome). For my solution you need to have an criteria to determine the parent with the draggable attribute (in my case I use a class name for that).

    function fixSelectable(oElement, bGotFocus)
    {
    	var oParent = oElement.parentNode;
    	while(oParent !== null && !/\bdraggable\b/.test(oParent.className))
    		oParent = oParent.parentNode;
    	if(oParent !== null)
    		oParent.draggable = !bGotFocus;
    }

    Text

提交回复
热议问题