jQuery查找功能需要帮助

the*_*man 2 jquery

这可能听起来有点愚蠢,但是请你指出为什么在下面的脚本中'firstValue'是未定义的,'secondValue'是根据需要,即4.

<div >
<input class="feedback-selected"  type="hidden" value="4" />
</div>    
<script type="text/javascript">

    var firstValue = $(this).find('.feedback-selected').val();
    var secondValue = $('.feedback-selected').val();
    alert(firstValue);
    alert(secondValue);

</script>
Run Code Online (Sandbox Code Playgroud)

我确信我没有使用find函数.

Phi*_*ert 5

在您的示例中没有值,因此find()函数将找不到任何内容.

(仅在实例函数或事件处理程序中有效)