dom - Accessing <span> node in Javascript -


I am trying to write a grezmanki script which only shows photos with tag bacon.

The site it runs on is written as:

   

Next I tried to use it to get the tag of this period:

  tagnodes = document.getElementsByClassName ('tag');  

And it returned an XPCNativeWrapper collection, all of which had undefined elements.

Any ideas about how to get a tag? I am quite new to javascript, so I'm sorry that my question is stupid.

[edit]

  var spans, tags; Spans = document.getElementsByTagName ('span'); For (var i = spans.length - 1; i> = 0; -i) {tag = spans [i]; Warning (tags.wrappedJSObject.nodeValue); }  

returns the blank with J. S. object as well. Is that because the Object.prototype does not work for XPCNativeWrapper? Using pure JavaScript (instead of using a library like jQuery - which I am don't / or

  var spans = document.getElementsByTagName ("span"); (Var i = spans.length - 1; i> gt; = 0; i--) {if (spans [i] .className == "tag") {var span = spans [i]; // something to do in jQuery code}}  

If you want to use jQuery, because you can do the code in jQuery:

 < Code> $ ("Span.tags"). Each (function () do something for {var span = this; // period});  

[edit]

One Once you have access to the duration with the tag in it, you need to get it innerHTML property.

This code will remove the entire list item, if the tag element does not have "bacon":

  var spans = document.getElementsByTagName ("span"); (Var i = spans.length - 1; i> gt; = 0; i--) {if (spans [i] .className == "tag") {var span = spans [i]; If (! Span.innerHTML.match (/ bacon / I)) {var le = span.parentElement.parentElement; Li.style.display = "none"; }}}  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -