例如:
<div id="title123">
    <input type="text" size="35" id="title" name="title" />
    ...
</div>
------------------------------------
用 $("#title123").html() 的时候只能获取对应的html标签,却无法获取输入的值。
如何才能同时获取title123下的所有内容及输入的值呢?

解决方案 »

  1.   


    额。。IE的还真可以那如果用的是其他浏览器有什么解决办法吗?比如chrome浏览器?
      

  2.   


    function getHhtml(){
       $('#title123 input').each(function(){ this.setAttribute('value',this.value)   });
       alert( $('#fBox').html()  ) 
    }
      

  3.   

    如何才能同时获取title123下的所有内容及输入的值呢?
    re:
    什么东东,还即要表单还要表单值.html肯定是没有输入值的,
      

  4.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <title>无标题文档</title>
    </head><body>
    <div id="title123">
        <input type="text" size="35" id="title" name="title" />
    </div>
    <input type="button" value="get" id="gFV" />
    <script type="text/javascript">
    jQuery(function(){

    $('#gFV').click(function(){
      $('#title123 input').each(function(){ 
    $(this).attr('value',$(this).val());   
    });
        alert($('#title123').html()) ;
    });
    });
    </script>
    </body>
    </html>
      

  5.   

    感谢楼上两位,附本菜鸟经常两位指导后的解决方法// 获取iframe内容兼容chrome
    function get_iframe_html(frameid) {
        var obj = $("#" + frameid);
        if ($.browser.msie) {
            //IE...
        } else {
            obj.contents().find("body").find("input").each(function (index) {
                if ($(this).attr("type").toLowerCase() == "radio" || $(this).attr("type").toLowerCase() == "checkbox") {
                    if ($(this).attr("checked")) {
                        this.setAttribute('checked', "true");
                    } else {
                        $(this).removeAttr("checked");
                    }
                } else {
                    this.setAttribute('value', this.value)
                }
            });        obj.contents().find("body").find("textarea").each(function (index) {
                $(this).html(this.value);
            });
        }
        return obj.contents().find("html").html();
    }