开发者

mark text onclick for all code tags

开发者 https://www.devze.com 2023-03-12 03:21 出处:网络
I use lots of code tags in a personal wiki (TiddlyWiki). I would like to have the text in the code tags automatically marked whenever I click on it.

I use lots of code tags in a personal wiki (TiddlyWiki). I would like to have the text in the code tags automatically marked whenever I click on it.

The problem is I can't add 开发者_Go百科onclick events inside the code tags.

Is it possible to add this in the JavaScript code? Something like:

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


Yes, you can do it.

Following are the list of attributes available for <code> tag.

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消