<!DOCTYPE html>
<html>
<head>
<title>DOM Range Example</title>
<script type="text/javascript">
function useRanges() {
var range1 = document.createRange(),
range2 = document.createRange(),
p1 = document.getElementById("p1"),
p1Index = -1,
i, len;
for (i=0, len=p1.parentNode.childNodes.length; i < len; i++) {
if (p1.parentNode.childNodes[i] == p1) {
p1Index = i;
break;
}
}
'
I find it in the javascript for web developer
here we can see p1Index = -1,why we don't use p1Index=0 ? '
Aucun commentaire:
Enregistrer un commentaire