0

I'm trying to access a series of span tags that begin with a certain string MTG_INSTR, but these span tags don't appear in the static HTML file that the website has when I view it on (rightclick -> view page source), but it does appear when I view it under (rightclick -> inspect -> elements), this is in chrome. I looked at the static HTML code and it has

<div id="ptifrmtarget"><iframe id="ptifrmtgtframe" name="TargetContent" 
title="Main Content" frameborder="0" scrolling="auto" onload="ptrc.onLoadTC()" 
src="URL EX" style="width: 1440px; height: 336px;"></iframe>    </div>

then when I view the page by inspect -> elements they insert a #document tag in between these two last tags in the original static HTML

</iframe>  
    #document 
       <!DOCTYPE html>
       <html class="pc chrome mac psc_dir-ltr psc_form-xlarge" dir="ltr" 
       lang="en">
       .....................................................................
       .....................................................................
       .....................................................................
       href="javascript:DoBack('win0')" style="visibility:hidden" aria-
       hidden="true">
       </a></div></body></html>

</div>

I deleted a lot of the code as it included many tables/table entries, eventually leading down to the desired span element that includes a teacher's name that I want to extract. There are a number of these teacher span tags that I want to grab and they follow this format

<div id="win0divMTG_INSTR$0"><span class="PSLONGEDITBOX" 
id="MTG_INSTR$0">EXAMPLE NAME</span>
</div>

I was told I could use jQuery since it works with current DOM objects but it doesn't currently work with this line

 $("span[id^=MTG_INSTR]").text('text');
Luke
  • 11
  • 1
  • 6

1 Answers1

1

You need to target the content of your <iframe>. Try:

$('#ptifrmtgtframe').contents().find("span[id^=MTG_INSTR]").text('text');
j08691
  • 204,283
  • 31
  • 260
  • 272