[英]Set input (without id, class or name) value inside iframe
I need to set a value to an input field that is located (deep) inside an iframe.我需要为位于 iframe 内部(深层)的输入字段设置一个值。 This input has no id, name or class.此输入没有 ID、名称或类。
Is this possible?这可能吗?
I can't simply add an id or the like because the code is coming from an outside source:我不能简单地添加 id 等,因为代码来自外部来源:
If there is only one <input>
element, you can refer to it by tag name.如果只有一个<input>
元素,可以通过标签名来引用。 With jQuery, you would write:使用 jQuery,你会写:
$("iframe#sq-postal-code").contents().find('input')
Note that this may fail with pages coming from outside, due to same origin policy enforced by modern browsers.请注意,由于现代浏览器强制执行的同源策略,这可能会因来自外部的页面而失败。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.