在我的主页iframe正在加载如下:
<div class="row iframe">
<iframe class="col-md-12 col-sm-12 col-lg-12" name="inlineframe" src="myphpfile" height="100%" width="100%" frameborder="0"></iframe>
</div>
此代码在不在iframe时工作正常,如何在iframe中运行此javascript。先谢谢了!
<script>
function checkthis()
{
$('#btn').prop('disabled', false);
}
</script>
<form name='opt' action='check' role='form' method='post'>
<label class='block'><input type='radio' name='ans' value='A' onclick='checkthis();'> $opt1</label>
<label class='block'><input type='radio' name='ans' value='B' onclick='checkthis();'> $opt2</label>
<label class='block'><input type='radio' name='ans' value='C' onclick='checkthis();'> $opt3</label>
<label class='block'><input type='radio' name='ans' value='D' onclick='checkthis();'> $opt4</label>
<div class='row top'>
<div class='col-md-6'>
<button class='btn' id='btn' disabled>Submit</button>
</div>
</div>
</form>
答案 0 :(得分:0)
请确保在iframe中调用jQuery.js - 否则iframe将无法运行jquery
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
function checkthis(){
$('#btn').prop('disabled', false);
}
</script>
<form name='opt' action='check' role='form' method='post'>
<label class='block'><input type='radio' name='ans' value='A' onclick='checkthis();'> $opt1</label>
<label class='block'><input type='radio' name='ans' value='B' onclick='checkthis();'> $opt2</label>
<label class='block'><input type='radio' name='ans' value='C' onclick='checkthis();'> $opt3</label>
<label class='block'><input type='radio' name='ans' value='D' onclick='checkthis();'> $opt4</label>
<div class='row top'>
<div class='col-md-6'>
<button class='btn' id='btn' disabled>Submit</button>
</div>
</div>
</form>