onblur for <div> is not working

onblur event for <div> tag is not working

Page 1 of 1

6 Replies - 15808 Views - Last Post: 23 February 2009 - 11:44 PM

#1 sutr_kam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 15-February 09

onblur for <div> is not working

Post icon  Posted 21 February 2009 - 04:52 AM

The onblur event for <div> or <table> is not working
while it is working for <input checkbox, text> fields


<div id="abc"  
	onblur="onblur();">
	<table style="border-top: none;color: black; border="0"  cellpadding="0" cellspacing="0" onblur="onblur();">
				<tr ><td width="100%"><span> Addresses</span></td></tr>
</table>
</div>



Is This A Good Question/Topic? 0
  • +

Replies To: onblur for <div> is not working

#2 JMRKER  Icon User is offline

  • D.I.C Addict

Reputation: 128
  • View blog
  • Posts: 828
  • Joined: 25-October 08

Re: onblur for <div> is not working

Posted 21 February 2009 - 07:37 AM

What are your expectations when you have not assigned an event action to the onblur event?

onblur=onblur(); doesn't do anything.
Was This Post Helpful? 0
  • +
  • -

#3 doWhileSomething  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 96
  • Joined: 08-January 09

Re: onblur for <div> is not working

Posted 23 February 2009 - 01:34 PM

View PostJMRKER, on 21 Feb, 2009 - 06:37 AM, said:

What are your expectations when you have not assigned an event action to the onblur event?

onblur=onblur(); doesn't do anything.



div elements do not support the onblur event. So, while JRMKER is correct in pointing out your method is wrong, even if it was correct it would not work.
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: onblur for <div> is not working

Posted 23 February 2009 - 01:42 PM

@doWhileSomething: I will have to respectfully disagree, a DIV does indeed have an onblur event (scroll down to DIV Methods & DIV Events), but you are correct in the OP needs to attach an event, onblur = onblur(); does nothing
Was This Post Helpful? 0
  • +
  • -

#5 doWhileSomething  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 96
  • Joined: 08-January 09

Re: onblur for <div> is not working

Posted 23 February 2009 - 02:44 PM

View PostPsychoCoder, on 23 Feb, 2009 - 12:42 PM, said:

@doWhileSomething: I will have to respectfully disagree, a DIV does indeed have an onblur event (scroll down to DIV Methods & DIV Events), but you are correct in the OP needs to attach an event, onblur = onblur(); does nothing


I see the article, however I've never seen it used anyplace. Do you have any examples? I myself have a need for this functionality.

I don't see how it can have/support an onblur event when it can't maintain focus. Again, not trying to argue the point, I will gladly stand corrected. I've never seen it used.
Was This Post Helpful? 0
  • +
  • -

#6 doWhileSomething  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 96
  • Joined: 08-January 09

Re: onblur for <div> is not working

Posted 23 February 2009 - 03:01 PM

I did some tests and I guess I stand "partialy" corrected.

IE will support onblur events on a div tag, while none of the other 3 major browsers do. In IE, it was spotty at best, and seems to only raise the onblur event when you either tab or give another element focus.

My appologies for giving such a literal statement, however support for this event on divs is specific to just IE and not very reliable.

:blink:
Was This Post Helpful? 0
  • +
  • -

#7 sutr_kam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 15-February 09

Re: onblur for <div> is not working

Posted 23 February 2009 - 11:44 PM

In fact I have given calling area only and I have onblur() function in the javascript it is working for table and not for div.
function onblur(){
if(document.all.show.value == "0"){
document.all.multiDropDown.style.visibility = "visible";
document.all.show.value = 1;
} else{
document.all.multiDropDown.style.visibility = "hidden";
document.all.show.value = 0;
}
}
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1