如何使用下拉列表在不同的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();