サイトのカスタム辞書にある場合、すべての href リンクをチェックする必要があるサイトがあります。それらが存在する場合、a-tag の title 属性は、サーバーから取得したテキストに設定する必要があります。私はこのサイトの他の問題に基づいてこれをまとめました(例、テストされていません):
// How to only activate "a href" links?
jQuery('a').mouseover(function() {
// should be what is between <a href="">this text</a>. Is this correct?
var dictionaryWord = jQuery(this).text();
// do a server site call to get description for the word given in the var above
jQuery.get("/getDescriptionFromDictionaryWord.aspx", { word: dictionaryWord },
function(data){
// set title tag for the a-tag actual a-tag
// will "this" refer to the a-tag with mouseover?
jQuery(this).attr("title", data);
});
});
上記に誤りがあるかもしれません。ここ StackOverflow で見つかったさまざまな回答から作成しました。上記よりもサーバーから応答を取得するためのより良い方法はありますか?
それが機能する場合、マウスオーバーでタイトルタグを表示する良い方法だけが必要です。私はそのためのいくつかのパッケージを見てきましたので、それは十分に簡単なはずです。
BR。アンダース
更新(以下の回答に基づく)
// all "a href" do this for the first mouseover "one.()"
jQuery('a[href]').one('mouseover',(function() {
// get a reference to the clicked + get dictionary word
var anchor = jQuery(this),
dictionaryWord = anchor.text();
// do a server site call to get description for the word given in the var above
jQuery.get("/getDescriptionFromDictionaryWord.aspx", { word: dictionaryWord },
function(data){
// set title tag for the a-tag actual a-tag
// will "this" refer to the a-tag with mouseover?
anchor.attr("title", data);
});
}));