2013-03-23 65 views

回答

4

是的,它當然有可能。以下代碼is demonstrated here,並在單擊文本時顯示源代碼。

Here's an example與頁面上的多個元素(被點擊時在文本框中顯示)。

<script type = "text/javascript"> 
function showSourceCode(toShow){ 
    sourceCode.value = toShow.innerHTML; 
} 
</script> 

<p onclick = "showSourceCode(this);"> 
    <b>Show source code on click!</b> 
</p> 

<input type="text" id = sourceCode></input> 


</body> 
</html> 
+0

@大衛是的,這將是合併到一個基於Web的一個非常有用的功能IDE。 – 2013-03-23 00:46:32

+0

outerHTML會更合適。 – Gael 2013-03-23 00:49:40

+0

@Gael Hm ...你可以在jsfiddle上發佈一個例子來展示你的意思嗎? – 2013-03-23 00:51:15