//jq var clonedEl = $('.el').clone(); //js var clonedEl = document.querySelector('.el').cloneNode(true);
移除
1 2 3 4 5
//jq $('.el').remove(); // js var toRemove = document.querySelector(el); toRemove.parentNode.removeChild(toRemove);
ajax
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
//jq $.get('url', function (data) { }); $.post('url', {data: data}, function (data) { }); //js // get var xhr = new XMLHttpRequest(); xhr.open('GET', url); xhr.onreadystatechange = function (data) { } xhr.send(); // post var xhr = new XMLHttpRequest() xhr.open('POST', url); xhr.onreadystatechange = function (data) { } xhr.send({data: data});
//jq $(el).removeClass(className); //js // removeClass, takes two params: element and classname function removeClass(el, cls) { var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)"); el.className = el.className.replace(reg, " ").replace(/(^\s*)|(\s*$)/g,""); }