onfocus="this.blur();" problem

Posted by carpenter on Stack Overflow See other posts from Stack Overflow or by carpenter
Published on 2010-03-15T11:41:14Z Indexed on 2010/03/15 11:59 UTC
Read the original article Hit count: 386

Filed under:
|
|
// I am trying to apply an "onfocus="this.blur();"" so as to remove the dotted border lines around pics that are being clicked-on
  // the effect should be applied to all thumb-nail links/a-tags within a div..

  // sudo code (where I am):
  $(".box a").focus(  // so as to effect only a tags within divs of class=box |  mousedown vs. onfocus vs. *** ?? | javascript/jquery... ???
  function () 
  {
      var num = $(this).attr('id').replace('link_no', ''); 
      alert("Link no. " + num + " was clicked on, but I would like an  onfocus=\"this.blur();\" effect to work here instead of the alert...");

      // sudo bits of code that I'm after:
      // $('#link_no' + num).blur();
      // $(this).blur();
      // $(this).onfocus = function () { this.blur(); };


  }
  );

 // the below works for me in firefox and ie also, but I would like it to effect only a tags within my div with class="box"
   function blurAnchors2() 
             {
              if (document.getElementsByTagName) {
                   var a = document.getElementsByTagName("a"); 
                    for (var i = 0; i < a.length; i++) {
                          a[i].onfocus = function () { this.blur(); };
              }
                }
          }

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript