简体   繁体   English

从 object 检索数据

[英]Retrieve data from an object

<script>
    $(document).ready(function() {
     var k = $('.tren li').filter(':not(:first):not(:last)');
        alert(k[0]);
    });
</script>

Live: http://jsfiddle.net/D9NTr/直播: http://jsfiddle.net/D9NTr/

It returns a message like [OBJECT HTMLLI ELEMENT] .它返回类似[OBJECT HTMLLI ELEMENT]的消息。 How can I retrieve the value of the object?如何检索 object 的值?

You need to use the text() method like:您需要使用text() 方法,例如:

alert(k[0].text());

I'll knock up a quick jsfiddle to demonstrate.我会敲一个快速的 jsfiddle 来演示。

Not applicable to your example.不适用于您的示例。 But if you need the html, then k[0].html()但是如果你需要 html,那么k[0].html()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM