getElementsByID - HELP!

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
bluefairy
Forum Newbie
Posts: 9
Joined: Fri Sep 17, 2010 9:27 pm

getElementsByID - HELP!

Post 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>';
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: getElementsByID - HELP!

Post by Jonah Bron »

Your question isn't clear. Do you mean you want to hide the <span> with the id 'drawingpix1'?
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: getElementsByID - HELP!

Post by Darhazer »

the id is actually drawingpix1
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: getElementsByID - HELP!

Post by Jonah Bron »

@Darhazer: isn't that what I said?
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: getElementsByID - HELP!

Post by Darhazer »

Jonah Bron wrote:@Darhazer: isn't that what I said?
well, yeah, my mistake ;)
Post Reply