2011-06-09 55 views
0

我在個人wiki(TiddlyWiki)中使用了很多代碼標記。我希望每當點擊它時,代碼標籤中的文本都會自動標記出來。標記文字onclick所有代碼標記

問題是我無法在代碼標籤內添加onclick事件。

是否有可能在JavaScript代碼中添加此項?例如:

document.body.getElementsByTagName("code") if onclick select(); 

回答

1

是的,你可以做到。

以下是可用於<code>標記的屬性列表。

dir   Specifies the direction of the text 
class  Document wide identifier. 
id   Document wide identifier 
lang  Language code 
title  Specifies a title to associate with the element. Many browsers will display this when the cursor hovers over the element (similar to a "tool tip"). 
style  Inline style (CSS) 
onclick  Intrinsic event (see event handlers) 
ondbclick Intrinsic event (see event handlers) 
onmousedown Intrinsic event (see event handlers) 
onmouseup Intrinsic event (see event handlers) 
onmouseover Intrinsic event (see event handlers) 
onmousemove Intrinsic event (see event handlers) 
onmouseout Intrinsic event (see event handlers) 
onkeypress Intrinsic event (see event handlers) 
onkeydown Intrinsic event (see event handlers) 
onkeyup  Intrinsic event (see event handlers)