Jump to content

What is this Solved with thanks


niche

Recommended Posts

I can't find a ref for the double question marks.

document.getElementById('cursorY').value = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);}

Do you have one?

Edited by niche
Link to comment
Share on other sites

I know the simple ternary reads if-then-else. How does the one in the op read?

Link to comment
Share on other sites

Ternary operators can be nested just like if/else statements. When expanded, the ternary in the OP might look something like this:

var val; // Start of the ternary syntax conversionif (window.Event) { //Condition from first ternary	//"True" portion of first ternary	val = e.pageY;} else {	//"False" or "else" portion of first ternary	val = event.clientY;	if (document.documentElement.scrollTop) { //Condition from second ternary		//"True" portion of second ternary		val += document.documentElement.scrollTop;	} else {		//"False" or "else" portion of second ternary		val += document.body.scrollTop;	}}//End of the ternary syntax conversion document.getElementById('cursorY').value = val;

Edited by ShadowMage
  • Like 1
Link to comment
Share on other sites

Outstanding topic ShadowMage & justsomeguy. Thanks for all the extra attention to detail ShadowMage. It's appreciated very much. Niche

Edited by niche
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...