SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2010
    0 Post(s)
    0 Thread(s)

    Is it possible to change styling w/ javascript, onload, after the targeted tag?

    Okay, here's my ordeal. I've been given the task of designing within this incredibly rigid site builder program of a clients (seriously I think it's coding circa 1995). I've got a design, but we've had some browser complications. Like I said this thing is very particular, the only way I can change anything is by adding snippets of code in a custom html form that they have. Working everything around, I've had to position an image absolutely so it doesn't expand the body of the page. This though has conflicted with some hover over dropdown submenus. I've figured out that if I can just change that style to the next z-index level it could work. I can't place any kind of code above this instance, so I wondered if I would be able to do this with javascript using a window.onload call? It's been awhile since I've done anything with javascript, so I'm not entirely sure how to do this, or for that matter if it's even possible.

    One other thing, this is called on by a class. I know I can't use getElementByID, but think it might be possible to use getElementByTagName ('ul') to do this.

    Any ideas? Is this even possible?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    West Springfield, Massachusetts
    196 Post(s)
    2 Thread(s)
    Well, the code will be a lot more verbose without an id to go after, but as long as you have the DOM it should be possible.

    You could try XPATH or maybe something like

    var allTargetElementsNodeList = document.getElementsByTagName('whatever');
    for (.....){
    if ( allTargetElementsNodeList[i].hasAttribute('something')
    and allTargetElementsNodeList[i].getAttribute('something') == 'value' ){

    You may need to use a bunch of childNode / parentNode too.

    Not pretty, but possible.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts