I have the following code but it cannot be directly edited
<div class="slide-content">
<iframe src="sdsdsds" width="640" height="360" frameborder="0" title="Bing" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</li>
<li class="slide" data-thumb="sdsdsdsd">
<div class="slide-content">
<iframe src="sdsdsdsd" width="640" height="360" frameborder="0" title="Walmart" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</li>
I want to set IDs for the iframes so they become like so
<iframe id="IFRAME1" src="sdsdsds" width="640" height="360" frameborder="0" title="Bing" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
I'm somewhat proficient in PHP but don't know how to do this; this would have to be in the code and set through some way.
Help! :-)
If you know the src=
attributes, you can do this with JavaScript. I know that's not what you asked for, but I believe it'll work.
You can get a collection of iframe
elements with document.getElementsByTagName('iframe')
. A collection behaves like an array, so you can iterate over it. Check the src=
attribute (available in the .src
property), figure out the ID you want to use, and use setAttribute("id", "whatever");
to set an ID on each iframe. You can hook this to onload
and the iframes will have IDs when you need them.