getElementsByID - HELP!
Posted: 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>';