[英]How to append <li> tag at the top inside <ul> with help of jquery in laravel?
I am developing notification dropdown for my website.我正在为我的网站开发通知下拉列表。 for that i am trying to append
<li>
tag at the top of drop down.为此,我正在尝试在下拉列表顶部添加 append
<li>
标签。 but currently it is appending at bottom of <ul>
.但目前它附加在
<ul>
的底部。
i tried to add new ul
tag but i think that is not good practice.我尝试添加新的
ul
标签,但我认为这不是一个好习惯。
html html
<ul class="dropdown notifications no-hover closed notilist">
@foreach(Auth::user()->notifications->take(4) as $notification)
@if(!empty($notification['data']['sender_name']))
<li class='dropdown-item'><b>{{$notification['data']['sender_name']}}</b> Bid on your Auction <b>{{$notification['data']['product_title']}}</b> of <b>{{$notification['data']['bid']}}$</b>
</li>
@endif
@endforeach
</ul>
jquery jquery
Echo.private('App.User.'+userId)
.notification((notification) => {
$('.notilist').append("<li class='dropdown-item'><b> "+notification.sender_name+"</b> Bid on your Auction <b>"+notification.product_title+"</b> of <b>"+notification.bid+"</b>$</li>")
});
I want to append that new <li>
tag at the top.我想 append 顶部的新
<li>
标签。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.