开发者

Display the same title text for all elements of the same class?

Lets say I want to display tool tips for links using the title attribute:

   <a class="editcommand" title="Edit" ...>

Is there a way to specify the 开发者_如何转开发title text for all elements of the same class using CSS, so I don't have to repeat it within each element?


CSS is only for the content of the style="" attribute, not other HTML tags. This sounds like a job for Javascript. If you're using jQuery here's an example:

$('a').attr('title', 'My universal title');


Unfortunately, no, CSS does not provide that ability. Since title is an HTML attribute (besides the <title> element of course), it's up to the markup structure (DOM) to define it, not the style (CSS).

With JavaScript it's just a matter of attaching the attribute to a set of DOM elements with that class. But again, that's modifying the DOM elements themselves, not their style properties.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜