CSSを使用して要素の属性を変更することはできません。あなたは、おそらく、(のみ不器用ながらも)しかし、title
機能をエミュレートできます。
.note {
position: relative;
}
.note:after {
content: "The alternate 'pseudo-title' text for the .note elements.";
position: absolute;
left: 50%;
background-color: #000;
color: #fff;
}
JS Fiddle demoを。
これを使用すると元のtitle
が表示されるので、JavaScript(またはサーバー側言語)でその属性を削除することをおすすめします。
可能なJavaScriptのタイトル除去方法:
var notes = document.getElementsByClassName('note');
var notesNum = notes.length;
for (i=0; i<notesNum; i++){
notes[i].removeAttribute('title');
}
JS Fiddle demo (combining the two approaches)。
はコメント(下記)クラス名を持つすべての要素の新しいタイトルを割り当てるには、JavaScriptのオプションを追加するために、既存の外観を変更し、感じるしたくないから、OPとして、を編集します
note
:
var notes = document.getElementsByClassName('note');
var notesNum = notes.length;
var newTextForNotesClass = "This is the new title text for the notes-class-name group.";
for (i=0; i<notesNum; i++){
notes[i].title = newTextForNotesClass;
}
JS Fiddle demoです。
CSSはプレゼンテーションやスタイルに関係しています。タイトル属性はデータであり、プレゼンテーションではありません。 – cdhowie
@cdhowie:実際には、タイトルは実際にはプレゼンテーション用のものでデータではありません。 –