Javascript Onclick Not Working On Ios
I have developed code which detects when a user clicks on a cell in a table, and then uses the bgColor that has been set for that cell. All works fine on the desktop computer, but
Solution 1:
what about this handle function?
functionhandler(e){
e.target.nodeName!='TD'||alert(e.target.bgColor+' on '+
e.target.parentNode.parentNode.parentNode.id);
}
window.addEventListener('click',handler,false);
or
window.addEventListener('touchstart',handler,false);
demo
with multiple tables
http://jsfiddle.net/gfmbkmmn/1/
the above function is an alternative solution to handle multiple tables with one event handler. to find your error more info is needed:
note: in ios is better that you write window.onload, and what about the script tags in your "current code", what does the getVal function?
if you have any questions about the code just ask
EDIT
functiongetVal(e){
e=e||window.event;//not needed
e.target=e.target||e.srcElement;//not neededif(e.target.nodeName=='TD'){// check if it's a tdalert(e.target.bgColor);// why write 'targ.attributes.bgcolor.value' ?
}
}
the node bug is from 7 years ago "Changed 7 years ago by ..." http://bugs.jquery.com/ticket/1148
js is case sensitive : bgcolor != bgColor
http://jsfiddle.net/gfmbkmmn/2/ this basic example allows you to create a fast color palette.
Post a Comment for "Javascript Onclick Not Working On Ios"