I downloaded sizzle.js from https://github.com/jquery/sizzle my code is:
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="sizzle.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload=load;
function load(){
alert(Sizzle("#test"));
alert(Sizzle("#test").innerHTML);
}
</script>
</head>
<body>
<div id="test">abc</div>
</body>
</html>
but alert "[object]", "undefined", please tell me what's wrong with my code?
The Sizzle()
function returns an array of matched elements. So if you know there'll be exactly one matching element (which there should be if you're selecting by id) try:
alert(Sizzle("#test")[0].innerHTML);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With