jquery 反转 dom元素

12-02 1,840 views

例:

<ul>
  <li>A</li>
  <li>B</li>
  <li>C</li>
</ul>

需要变成:

<ul>
  <li>C</li>
  <li>B</li>
  <li>A</li>
</ul>

代码:

$(function(){
     var list = $('ul');
     var listItems = list.children('li');
     list.append(listItems.get().reverse());
})

参考: https://stackoverflow.com/questions/5347839/jquery-reversing-the-order-of-child-elements

js给当前url添加get参数,兼容旧参数

example updateQueryStringParameter("https://www.baidu.com?a=123",'b','hello') //result https://www.baidu.com/?a=123&b...

阅读全文

使用js弹出chrome windows通知提醒

废话少说,直接上代码 function notifyMe(notification_title, body) { if (Notification.permission !== "granted") Notification.re...

阅读全文

dropzone 插件只上传一张图片

<div> <div class="col-md-3"> <div class="form-group"> <label>你的头像</label> ...

阅读全文

欢迎留言