javascript - jQuery won't select tag? -


jquery telling me cannot find tag i'm asking select. have similar select works fine.

here's selecting code:

$(".pagename.ent0#1401183013"); 

here's tag looks like:

<div class="pagename ent0" id="1401183013">/</div> 

when write console.log($(".pagename.ent0#1401183013").length) gives me 0. it's on timer there continuous pile of these tags same attributes, tells me 0 every time. copy+paste examples output.

i tried in jsfiddle and, expected, worked fine, in implementation doesn't.

var inputlog = json.parse('<?php echo $jslog ?>'); var numofpings = 0;    var inputlogstartind = -1; var thissecond = '<?php echo $starttime ?>'; for(var = 0; < inputlog.length; i++){     if(inputlog[i].time >= thissecond){         inputlogstartind = i;         thissecond = inputlog[i].time;         break;     } } if(inputlogstartind!=-1){    var bncenxcoord = '70%'; var bncstxcoord = '70%'; var thislogind = inputlogstartind; console.log("thislogind: "+thislogind); console.log(inputlog[thislogind]); var pageslisted = new array(); setinterval(function(){     console.log(inputlog[thislogind].time);     console.log(thissecond+"\n");     if(inputlog[thislogind].time==thissecond){         var entcount = 0;         while(inputlog[thislogind].time==thissecond){             $(".phppongtable #pages").append('<div class="pagename ent'+entcount+'" id="'+thissecond+'">'+inputlog[thislogind].file+'</div>'); // make pageslisted handle duplicates             $(".phppongtable #ips").append('<div class="ipadd ent'+entcount+'" id="'+thissecond+'">'+inputlog[thislogind].ip+'</div>'); // make ipslisted handle duplicates             console.log($('.ipadd.ent'+entcount+'#'+thissecond)); // returns tag             var ipaddtop = ($('.ipadd.ent'+entcount+'#'+thissecond).offset().top - $(window).scrolltop());             var ipaddleft = ($('.ipadd.ent'+entcount+'#'+thissecond).offset().left);             $("body").append(                 '<div class=".circle ent'+entcount+'" id="'+thissecond+'" \                 style="position:absolute;\                 top:'+ipaddtop+';\                 left:'+ipaddleft+';">0</div>');             console.log($('.pagename.ent'+entcount+'#'+thissecond).length); // outputs 0 time             /////*error occurs here (uncaught typeerror: cannot read property 'top' of undefined )*/////             var pagenametop = ($('.pagename.ent'+entcount+'#'+thissecond).offset().top - $(window).scrolltop());             var pagenameleft = ($('.pagename.ent'+entcount+'#'+thissecond).offset().left);             $('.circle.ent'+entcount+'#'+thissecond).animate({                 'top':pagenametop,                 'left':pagenameleft             },2000,             function(){                 $(this).animate({                     'left':ipaddleft,                     'top':ipaddtop                 });             });             thislogind++;             entcount++;         }     }            thissecond++;     console.log("thisnewsecond: "+thissecond); },1000);  } else {     console.log("no log entries"); } 

the attributes class , id dom element shouldn't start number. try put char before number , should work.

if have several class or id in app starting number, possible workaround follow, suggested here: http://css-tricks.com/ids-cannot-start-with-a-number/

[id='1800number_box'] {  /* work */ }  #1800number_box {   /* doesn't work */ } 

another possible workaround follow:

<body id="69">  body#\36 9 p { color: red; } 

where \36 utf-8 code number 6, , has followed space (which disregarded) engine knows it’s end of code. described here http://www.markinns.com/articles/full/using_numbers_as_css_class_or_id_values

these examples styling css only, same procedure can done selecting dom element jquery.

anyway suggest use names start string (no digits), in manner easier read code.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -