如何使用下拉列表在不同的id或类中显示iframe [英] How to show iframe in diffrent id or class with dropdown

查看:90
本文介绍了如何使用下拉列表在不同的id或类中显示iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以用这种方法显示图像:



php代码:

I am able to show an image with this method:

php code:

<div class="sidebar">
  <td>Choose Image</td>

        <td><select name="image" class="image" id="image">
        <option value="">--Choose Image--</option>
        <option value="image1.jpg">Image1</option>
        <option value="image2.jpg">Image2</option>
        </select>
        </td>

    <!-- end .sidebar --></div>

<div class="content" id="content">
    <!-- the image will show here -->
	</div>





js代码:



js code:

$(document).ready(function() {
 $("#image").change(function() {
        var src = $(this).val();

        $("#content").html(src ? "<img src='" + src + "'>" : "");
    });
});





现在的问题是如何用该代码显示iframe?

我试过这个



php code:





Now the question is how to show iframe with that code??
I tried like this

php code:

<div class="sidebar">
  <td>Choose Iframe</td>

        <td><select name="show_iframe" class="show_iframe" id="show_iframe">
        <option value="">--Choose Iframe--</option>
        <option value="view/iframe1.html">Iframe 1</option>
        <option value="view/iframe2.html">Iframe 2</option>
        </select>
        </td>

    <!-- end .sidebar --></div>

<div class="content" id="content">
    <!-- I want the ifram show here -->
	</div>





和js代码变为:



and the js code become:

$(document).ready(function() {
 $("#show_iframe").change(function() {
        var src = $(this).val();

        $("#content").html(src ? "<iframe src='" + src + "'>""</iframe>" : "");
    });
});





任何人都可以帮助我吗??

请给我一个方法下拉列表更改时显示iframe ...



Can anyone help me??
Please show me a way to show iframe when the dropdown list change...

推荐答案

(document).ready(function(){
(document).ready(function() {


( #image)。change(function(){
var src =
("#image").change(function() { var src =


(this).val();
(this).val();


这篇关于如何使用下拉列表在不同的id或类中显示iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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