JavaScript and client side scripting.
Moderator: General Moderators
bluefairy
Forum Newbie
Posts: 9 Joined: Fri Sep 17, 2010 9:27 pm
Post
by bluefairy » Sat Feb 12, 2011 9:27 am
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>';
Jonah Bron
DevNet Master
Posts: 2764 Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California
Post
by Jonah Bron » Wed Feb 16, 2011 9:58 pm
Your question isn't clear. Do you mean you want to hide the <span> with the id 'drawingpix1'?
Darhazer
DevNet Resident
Posts: 1011 Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria
Post
by Darhazer » Thu Feb 17, 2011 7:25 am
the id is actually drawingpix1
Jonah Bron
DevNet Master
Posts: 2764 Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California
Post
by Jonah Bron » Thu Feb 17, 2011 10:36 am
@Darhazer: isn't that what I said?
Darhazer
DevNet Resident
Posts: 1011 Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria
Post
by Darhazer » Thu Feb 17, 2011 11:07 am
Jonah Bron wrote: @Darhazer: isn't that what I said?
well, yeah, my mistake