Reputation: 4919
I have a html document that has this structure:
https://i.sstatic.net/zrOq1.png <- sorry for link, but I can't place imeges inside question
I would like to get from my iframe to it inside parent document.
The simplest way would be to give my iframe id, but I can't do that.
In my iframe I have a selector like this:
$("table.TitleText > tbody > tr > td.TitleText",parent.document)
but it gives me two or three elements in my parent document.
I need to check if this td has text "MY NAME" in it, then do parent 9 times and then get next tr, then div with class 'contentNode' and iframe in it.
I know it sounds crazy, but I don't know how to do it another way :/
I need a selector that will find firsth iframe after TD containing "MY NAME", so I can change it height
Could anyone help me?
Upvotes: 0
Views: 2672
Reputation: 69915
You can use closest()
method to get the td
with id
"title-bar" and its parent
will give the tr
which is at 9th parent level from the td
containing "MY NAME"(which is what you are looking for). And then next()
will give you the next tr
and use find()
method to get the contentNode
within that tr
.
$("table.TitleText td.TitleText:contains('MY NAME')")
.closest('#title-bar')
.parent() //will give the tr
.next() //will give next tr
.find('#contentNode')
Ideally ids should be uinique on the page in that case you can just use id selector to select contentNode
div element.
$('#contentNode');
Upvotes: 1