Skip to content

Instantly share code, notes, and snippets.

@tvandervossen
Created September 25, 2010 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvandervossen/596593 to your computer and use it in GitHub Desktop.
Save tvandervossen/596593 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="zepto_original.js"></script>
</head>
<body>
<div id="canvas"><div id="slide1"><img></div></div>
<script>
var slide = $('#slide1');
console.log(slide.get(0)); // Returns div element.
var img = $('#slide1 img');
console.log(slide.get(0)); // Should return div element, but returns img element instead.
</script>
</body>
</html>
@mstffn
Copy link

mstffn commented Sep 25, 2010

edit:

Strange, maybe this has something to do how console.log() internaly works.. try this..

setTimeout(function(){
  var img = $('#slide1 img');
 },0);
console.log(slide.get(0));

..works

also alert() works fine..

@tvandervossen
Copy link
Author

@mstffn
Copy link

mstffn commented Sep 25, 2010

Yeah, I see.. also my example was unreasonable..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment