2012-10-19 24 views
0

在我的html頁面中我有一個texteare,我會寫一些內容給它,我想要一些內容可以修改但是有些不能。如何使內容的某些部分無法在html textarea中編輯

<html> 
    <body> 
    <div class="text"> 
    <textarea cols="50" rows="4" name="msg_content" id="msg_content" readonly="readonly"> 
     Hi, I am the contents that can be modified. 
     Hi, the url cannot be modified. 

     http://www.google.com 
    </textarea> 
    </div> 
</html> 

當你看到我做的textarea的歡迎使用屬性之一是隻讀的,但在這種情況下,整個內容不能被修改。

可否請給我一些建議,在此先感謝。

回答

0

這是不可能的,除非你可以使用HTML5。使用HTML5,您可以針對特定元素使用contenteditable = true/false屬性。

在這裏你去一個例子:

<div contenteditable="true"> 
You can edit this text, 
<p contenteditable="false">but not this one.</p> 
</div> 
+0

感謝salih0vicX,在這裏我只能用texteara – diligent

+0

在IE11不工作:http://plnkr.co/edit/eRhuzAwcxCVaLsbMn6sY ?p =預覽,但適用於Chrome和Firefox。編輯內容時,Chrome只顯示邊框。 – Sebastian

相關問題