Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
JS: getAttribute problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side
View previous topic :: View next topic  
Author Message
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 03.12.2006 16:09    Post subject: JS: getAttribute problem Add user to your forum ignore list Reply with quote

Code:
function exitLinks() {
   var exitLink=document.getElementsByTagName('a');
   for (var i = 0; i<exitLink.length; i++) {
         if (exitLink[i].getAttribute("rel") == "offsite") {
            exitLink[i].className = 'exit';
         }
      }
   }
}

pozivanje funkcije i dohvaćanje linkova radi, ali ovaj getAttribute neće.
pokušavam dobiti klasu za IE pošto ne kuži a[rel~="offsite"]

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
Back to top
View user's profile Send private message Visit poster's website Twitter profile
strija



Joined: 14 Sep 2003
Posts: 473
Location: Čakovec

PostPosted: 03.12.2006 16:30    Post subject: Add user to your forum ignore list Reply with quote

Najjednostavnije sa npr. JQuery. Pa bi izgledalo ovako:
Code:
$("a[@rel=offsite]").addClass("exit");

_________________
We can exist in ambiguity, but it means the deepest loneliness. | creolab.hr | thefarewellreason.com
Back to top
View user's profile Send private message Visit poster's website
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 03.12.2006 16:55    Post subject: Add user to your forum ignore list Reply with quote

hvala.
samo mi je malo bezveze imati library od 1000 linija ako koristim jednu-dvije funkcije. uopce se ne snalazim u njemu pa ne mogu izbrisati stvari koje mi ne trebaju Confused

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
Back to top
View user's profile Send private message Visit poster's website Twitter profile
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 03.12.2006 17:31    Post subject: Add user to your forum ignore list Reply with quote

Sve linkove dohvatiš sa document.links
Atribut dohvatiš direktno: link.rel
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 03.12.2006 17:38    Post subject: Add user to your forum ignore list Reply with quote

ok i to bi onda izgledalo ovako?
Code:
function exitLinks() {
   var exitLink=document.links;
   for (var i = 0; i<exitLink.length; i++) {
         if (exitLink[i].rel == "offsite") {
            exitLink[i].className = 'exit';
         }
      }
   }
}

Question

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
Back to top
View user's profile Send private message Visit poster's website Twitter profile
strija



Joined: 14 Sep 2003
Posts: 473
Location: Čakovec

PostPosted: 04.12.2006 12:25    Post subject: Add user to your forum ignore list Reply with quote

Da JQuery je malo velik ako ti treba samo za ovo, ali je u jednoj liniji koda Smile
Moze i ovako kao sto si zadnje napisala, trebalo bi raditi.

_________________
We can exist in ambiguity, but it means the deepest loneliness. | creolab.hr | thefarewellreason.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group