-4

First I know the title isn't the best nor what the site recommends/asks for, but I have no idea how else to put it.

I'm using JQuery to edit twitter widgets on my website. I had no problem doing so until this one element.

I have checked that I'm searching for the correct element timeline-Widget and what I'm trying to edit is the border-radius

enter image description here

snippet of my code:

$('.twitter-block').find('.twitter-timeline').css({"border": "4px solid rgb(255, 225, 241)", "outline" : "8px solid rgb(255, 189, 225)"});
$('.twitter-block').find('.timeline-Widget').css({"border-radius": "0px"});

first line edits twitter-timeline element and it works just fine, but timeline-Widget JQuery just does not find.

Sorry, this is my first time working on a website and a first time working with JS and JQuery

  • 1
    Hi! Please take the [tour], have a look around, and read through the [help], in particular [*How do I ask a good question?*](/help/how-to-ask) Please post code, error messages, markup, etc. **as text**, not as a *picture* of text. Why: http://meta.stackoverflow.com/q/285551/157247 – T.J. Crowder Apr 17 '21 at 09:56
  • 3
    `find` will only look for elements in the current document, but the image suggests that the `.timeline-Widget` element is not in the current document, but in a child document. You would need a reference to that document first... – trincot Apr 17 '21 at 09:59
  • @barmar sorry, I took a better screenshot and edited my question. – Vojtěch Vach Apr 17 '21 at 10:02
  • 1
    A selector can't cross into an iframe. – Barmar Apr 17 '21 at 10:02
  • An iframe with no src attribute, this is not the way jQuery find() works – Masood Apr 17 '21 at 10:10

1 Answers1

1

from jQuery own documentation:

 the .find() method allows us to search through the descendants of these elements 
 in the DOM tree and construct a new jQuery object from the matching elements

meaning the div twitter-block needs to be the parent of the timeline-Widget in order for it to be found, but from the looks of it the timeline-Widget is the first child of the body element