开发者

view contents of HTMLElement in Google Chrome?

I've got a HTMLElement and I'd like to view the contents of the object. A simple for loop follow开发者_Go百科ed by printing doesn't work as it wont convert to a primative type. I'm wondering how else can I do this with ease?


console.log(focusElement.innerHTML)


This isn't just chrome, but I usually have something like this if I want debugging in my application:

<script>
    var debug = true;

    function log(msg) {
        if(debug) {
            try {
                console.log(msg);
            } catch(e) {
                try {
                    throw new Error(msg);
                } catch(e) {
                    alert(msg);
                }
            }
        }
    }

    log("Debug mode is turned on");
    log($("#test"));   
</script>


<div id="test" style="display:none;">this came from a div</div>

--> example <--

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜