ProstAP03
ProstAP03
co robię źle?

request("[https://xd.xd](https://xd.xd/)", function(err, resp, body){
var $ = cheerio.load(body);
var idArray = [];
$('div.post').each(function(){
var postId = $(this).attr('id');
if ($(this).classList.contains('sticky')) {
console.log("sticky");
} else {
console.log("nie sticky");
}
//idArray.push(postId);
//console.log(postId);
});
//console.log(idArray);
});

(to co jest zakomentowane bylo wczesniej i bez if i działało, jak dałem to if to nie działa ( ͡° ʖ̯ ͡°))

co robię źle?

#webdev #javascript
  • Najlepsze
  • Wszystkie komentarze
mirasKo-Kalwario
mirasKo-Kalwario
@ProstAP03: w warunku powinno byc contains() != -1 bo jesli sticky bylo jedyną klasą i pierwszą to warunek zawsze był fałszywy bo contains zwracało 0
Zero
Zero
0
@ProstAP03: jaki error masz
Melcma
$(this).classList


@ProstAP03: to zwraca ci jakas liste czy sie psuje na tym etapie?
Daredzik
Daredzik
@ProstAP03: skoro już używasz jQuery no to nie classList tylko hasClass
ProstAP03
ProstAP03
ProstAP03 Autor
0
Cannot read property 'parent' of undefined
@Zero:
ProstAP03
ProstAP03
ProstAP03 Autor
0
@Melcma: nie zwraca, ten sam błąd
ProstAP03
ProstAP03
ProstAP03 Autor
0
@findesiecle: @Melcma: @Zero: Poradziłem sobie (。◕‿‿◕。)
billy0o
@ProstAP03: adres sie nie zgadza xd


xd
ProstAP03
ProstAP03
ProstAP03 Autor
0
@mirasKo-Kalwario: racja, ale nigdy tak nie jest.
ProstAP03
ProstAP03
ProstAP03 Autor
0
@mirasKo-Kalwario: teraz natrafiłem na taki problem, mógłbyś mi pomóc? ( ͡° ͜ʖ ͡°)

for(i=0;i0){
idArray = idArray.filter(item