为所有代码标记标记文本onclick

时间:2011-06-09 07:05:09

标签: javascript select onclick

我在个人维基(TiddlyWiki)中使用了大量代码标签。我想点击它时会自动标记代码标签中的文字。

问题是我无法在代码标记内添加onclick事件。

是否可以在JavaScript代码中添加它?类似的东西:

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

1 个答案:

答案 0 :(得分: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)