Page 1 of 1

getElementsByID - HELP!

Posted: Sat Feb 12, 2011 9:27 am
by bluefairy
Does anyone knows how can I get the element of: drawingpix = $(\'<span>\').attr({id: \'drawingpix1\', class: \'drawingpix\' }).hide(); I used getElementById but it does not work.

Code: Select all

echo '<script type="text/javascript" > 
				
		
				//set drawmode false
				var draw= false;
				 
				$(document).ready(function() {
				//set it true on mousedown
				$(document).mousedown(function(){draw=true;});
				//reset it on mouseup
				$(document).mouseup(function(){draw=false;});
				 
				 
				var drawingpix;
				$(document).mousemove(function(e) {
					if(draw==true){
						drawingpix = $(\'<span>\').attr({id: \'drawingpix1\', class: \'drawingpix\' }).hide();
						$(document.body).append(drawingpix);
			
						drawingpix.css({
							top: e.pageY,	//offsets
							left: e.pageX //offsets
						}).show();
					
				var s1 = document.getElementById(\'drawingpix\').toString();
						alert(s1);

					}		
				});
				});
					
					
				</script>';

Re: getElementsByID - HELP!

Posted: Wed Feb 16, 2011 9:58 pm
by Jonah Bron
Your question isn't clear. Do you mean you want to hide the <span> with the id 'drawingpix1'?

Re: getElementsByID - HELP!

Posted: Thu Feb 17, 2011 7:25 am
by Darhazer
the id is actually drawingpix1

Re: getElementsByID - HELP!

Posted: Thu Feb 17, 2011 10:36 am
by Jonah Bron
@Darhazer: isn't that what I said?

Re: getElementsByID - HELP!

Posted: Thu Feb 17, 2011 11:07 am
by Darhazer
Jonah Bron wrote:@Darhazer: isn't that what I said?
well, yeah, my mistake ;)