Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery run serverside script when mouseover
    text
    copied!<p>I have a site where I need to check all href-links if they are in a custom dictionary on the site. If they exist then the title attribute in the a-tag should be set to the text that is fetched from the server. I put this together based on other wuestions from this site (example, not tested): </p> <pre><code>// How to only activate "a href" links? jQuery('a').mouseover(function() { // should be what is between &lt;a href=""&gt;this text&lt;/a&gt;. 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); }); }); </code></pre> <p>There may be errors in the above. I have just created it from different answers found in this here on StackOverflow. Is there a better way to do get a response from a server than the above?</p> <p>If it works I only need a nice way to show the title tag on mouseover. I have seen some packages for that so that should be easy enough.</p> <p>BR. Anders</p> <p>UPDATE (based on answers below)</p> <pre><code>// 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); }); })); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload