javascript - Adding existing canvas to a div dynamically -
i have problem adding existing canvas div dynamically via jquery. try numerous options append 1 works.
here code:
<div class="a"> <div id="b"></div> <div id="c" class="c"> </div> </div>
jquery:
$(document).ready(function() { if($('.mydivifload').text().length >= 0) { //$('canvas[class="canvasclass"]').appendto($('.c')); // doesn't work //$('canvas[class="canvasclass"]').append($('.c')); // doesn't work //var canv= $('canvas[class="canvasclass"]'); //doesn't work //document.getelementbyid('c').appendchild(canv) // doesn't work $('canvas.canvasclass').appendto('.c') $(function() { $(".a").hover(function() { $(".a").stop(true, false).animate({right: "0" }, 800, 'easeoutquint' ); }, function() { $(".a").stop(true, false).animate({right: "-245" }, 800, 'easeinquint' ); },1000); }); } });
if me grateful!
edit
if depends in code based on tutorial: http://w3lessons.info/demo/sliding-facebook-likebox/
four things:
in css, identifiers ((you've said below aren't realid
values, class names) cannot start digit, selector.3
invalid (as selector#1
, etc.).id
s , classes, , real ones don't start digits.)consider startingid
s , class names letter selectors valid.your
appendto
, notappend
, right way go, selector problem.canvas[class="canvasclass"]
lookscanvas
exactly classcanvasclass
, no others. it'll match<canvas class="canvasclass">..</canvas>"
not<canvas class="foo canvasclass">..</canvas>
or similar. best way select class class selector,canvas.canvasclass
, match element class (even if has others).this suspect:
$('.mydivifload').val().length
. class suggests it'sdiv
,div
s don't have values. have contents. may want.text().length
or.html().length
or.children().length
or.contents().length
depending on goal line is.
Comments
Post a Comment