![]() |
[Solved!] Javascript: Using getElementById I'm not exactly the best or most experienced user with JavaScript, so I'll go ahead and ask. Basically, I want to inject some personal JavaScript for custom and client-side editing of the theme. This is necessary because of Jelsoft's horrible choice to use most styling inline instead of with IDs and classes. So, I want to add my own class to certain nested elements, so I can then edit the CSS properly. However, it's not just a child of one element, but very deeply nested within a lot of other elements that don't have an ID either. Ergo, usage of the getElementById is rather limited, because as far as I know, using: Code: document.getElementById('ID').children[x]# I'm looking for the following sequence of elements, whereas the last one is the one that's needs a new class: Code: div#posts > div > div.page > div > div > table.vbseo_like_postbit > tbody > tr > tdCode: window.onload = function() { |
Re: Javascript: Using getElementById Can't you use .childNodes.item(x).nodeValue ? if I remember correctly. Either that or try the lowest class on the chain - so for this one will be vbseo_like_postbit Also really? There are no ID's available? Le sigh. |
Re: Javascript: Using getElementById Solved by now. Thanks though. Turns out [with the help of Sheep & Cat] that I've been using the wrong approach. document.querySelectorAll() basically was what I needed. I then had to loop through its results, considering what is being returned is a NodeList (basically an array). PHP Code: |
Re: Javascript: Using getElementById Ever consider using jQuery? Code: $('.vbseo_like_postbit td[valign="bottom"]').each(function(key, value) { |
| All times are GMT -7. |
Powered by vBulletin®
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.