开发者

How to add | (pipe) between list with jquery

开发者 https://www.devze.com 2023-01-13 04:06 出处:网络
The following is created dynamically. <div id="footermenu"> <ul><li><a href="Nettbutikk.asp" title="" class="topactive">Nettbutikk</a

The following is created dynamically.

<div id="footermenu">
<ul><li><a href="Nettbutikk.asp" title="" class="topactive">Nettbutikk</a></li>
<li><a href="Infosenter.asp" title="" class="">Infosenter</a></li>
<li><a href="Kontakt_oss.asp" title="" class="">Kontakt oss</a></li>
</ul>
</div&g开发者_高级运维t;

With this text:

Nettbutikk Infosenter Koatakt oss

I'd like to add | between to make like this.

Nettbutikk | Infosenter | Koatakt oss

Nettbutikk etc will be changed in future, so I thought I should use li:first and li:nth-child(2).

I tried this but it gives an error telling:

TypeError: $("#footermenu ul li:first") is null { message="$("#footermenu ul li:first") is null", more...}

$("#footermenu ul li:first").append(' | ');

How can I do this?


Works for me. Are you sure you're including jQuery properly?

0

精彩评论

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