在iframe中获取单选值 [英] Get radio value inside iframe

查看:87
本文介绍了在iframe中获取单选值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何使用jQuery做到这一点?

How do I go about doing this with jQuery?

基本结构:

<form id="myForm">
  <iframe>
    <!-- Normal HTML headers omitted -->
    <input type=radio name="myRadio" value=1>First
    <input type=radio name="myRadio" value=2>Second
    <input type=radio name="myRadio" value=3>Third
  </iframe>
  <input type=button value="Submit" />
</form>

我从网上尝试了各种示例,例如

I tried various examples from the net such as

$("input[@type=radio][@checked]");

但是失败了.即使使用jQuery表单插件的 .fieldValue()也会失败.

But failed. Even with jQuery form plugin's .fieldValue() failed.

推荐答案

尝试$('#myForm iframe').contents().find('input[name=myradio]').val()

我假设iframe内容已经加载并且可以在同一个域中访问.

I'll assume that the iframe contents have already been loaded and are accessible e.g same domain.

这篇关于在iframe中获取单选值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆