SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    167
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Onblur Fails... Onclick works?!

    Why won't onblur work? onclick works!

    Code JavaScript:
    var allDivs = document.getElementsByTagName('div');
    for (var i=0; i< allDivs.length; i++)
    {
    	if (allDivs[i].className.indexOf('goal_icon_holder') != -1)
    	{
    		allDivs[i].onblur = function()
    		{
    			alert('test');
    		}
     
    		allDivs[i].onclick = function()
    		{
    			alert('test');
    		}
    	}
    }

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Onblur seems to only apply to elements that can gain focus, such as links and input fields.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •