1

The <head> contains:

<!-- Foo 1.2.3 by Author Bill -->
<!-- Foo 1.2.3 by Author Joe -->

I can only get this far with some code which may be wrong:

var hc = $('head')[0].childNodes;
for (var i = 0; i < hc.length; i++) {

    console.log(hc);

if (hc[i].nodeType == 8) { // comments have a nodeType of 8

// need something here to get a value and verify that one of the comments includes "Bill"
}
}
4

3 に答える 3

1

これは私のために働いた:

var hc = $('head')[0].childNodes;
for (var i = 0; i < hc.length; i++) {
    if (hc[i].nodeType == 8) { // comments have a nodeType of 8
         if(hc[i].nodeValue.indexOf("Bill") != -1){ 
              alert(hc[i].nodeValue);
         }
    }
}
于 2013-08-15T14:54:24.583 に答える