可能重複:
Is there a way to make a text area partially editable? (make only portions of the text editable)如何設置readOnly屬性設置所選文本的HTML文本區域內
如何設置readOnly屬性設置所選文本的HTML文本區域內的任何建議。 這裏是內textarea的選定的文本的圖像..
任何的指導和幫助表示讚賞..!
可能重複:
Is there a way to make a text area partially editable? (make only portions of the text editable)如何設置readOnly屬性設置所選文本的HTML文本區域內
如何設置readOnly屬性設置所選文本的HTML文本區域內的任何建議。 這裏是內textarea的選定的文本的圖像..
任何的指導和幫助表示讚賞..!
從我所瞭解的你想要的,here是一個工作解決方案。
下面是代碼:
$("#my-text").select(function() {
$(this).readonly = true;
});
$("#my-text").mouseup(function() {
$(this).readonly = false;
});
$("#my-text").keydown(function() {
$(this).readonly = false;
});
基本上我利用select
事件使textarea的readonly
。然後,使用removeAttr
刪除click
和上的read only
屬性。
感謝@Bergi指向jQuery對象的readonly
屬性。
是否可以將readOnly屬性設置爲選定的文本? – super
你有什麼嘗試? '這是textarea內部選定文本的圖像在哪裏? –
請檢查這個小提琴:http://jsfiddle.net/WSrww/ – super