【问题标题】:Show Auto complete responce multiple values显示自动完成响应多个值
【发布时间】:2016-12-30 12:41:58
【问题描述】:

我能够附加图像,并且我想在 Hallticket 号码中附加学生 ID,我该怎么做。? 这是我的html:

<td><b>Hallticket:</b>S<div><p class="hallticketNumber">***studentid has to come here***</p>J'+jobID+'</div></td>
<td><div><img class="participantphoto" src=""/><input class="searchStudent" type="text" autocomplete="off"><input class="studentId" type="hidden" name="gdtest['+studentCount+'][studentId]"></div></td>

这是我尝试过的:

$(this).closest('div').find(".studentId").attr("value",ui.item.student_pid);//working
$(this).closest('div').find(".participantphoto").attr("src",ui.item.profile_pic);//working
$(this).closest('div').find(".hallticketNumber").attr("label",ui.item.student_pid); //Notworking

错误在.attr("label",ui.item.student_pid);附近的最后一行

【问题讨论】:

    标签: javascript jquery jquery-ui jquery-ui-autocomplete


    【解决方案1】:

    使用text()动态改变段落内容。

    $(".hallticketNumber").text(ui.item.student_pid);
    

    【讨论】:

    • 只有一个段落

      标签的类是 hallticketNumber 吗?

    • $(this).closest('div') 不适用于 &lt;p class="hallticketNumber"&gt; ,因为它是一个不同的 div,然后被 &lt;img class="participantphoto" src=""/&gt;&lt;input class="searchStudent" .. &gt; 引用。如果只有一个 p 标签的类 hallticketNumber,请尝试上述解决方案
    • 如果我改变一个,我有可能所有

      都在改变,所以需要closet one 行.. @mhasan

    猜你喜欢
    • 2018-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-24
    相关资源
    最近更新 更多