you might not need jquery

What's the oldest version of IE you need to support? IE10

 

 1 /**json**/
 2 var request = new XMLHttpRequest();
 3 request.open('GET', '/my/url', true);
 4 
 5 request.onload = function() {
 6   if (this.status >= 200 && this.status < 400) {
 7     // Success!
 8     var data = JSON.parse(this.response);
 9   } else {
10     // We reached our target server, but it returned an error
11 
12   }
13 };
14 
15 request.onerror = function() {
16   // There was a connection error of some sort
17 };
18 
19 request.send();

 

 1 /**request**/
 2 var request = new XMLHttpRequest();
 3 request.open('GET', '/my/url', true);
 4 
 5 request.onload = function() {
 6   if (this.status >= 200 && this.status < 400) {
 7     // Success!
 8     var resp = this.response;
 9   } else {
10     // We reached our target server, but it returned an error
11 
12   }
13 };
14 
15 request.onerror = function() {
16   // There was a connection error of some sort
17 };
18 
19 request.send();

 

1 /**post**/
2 var request = new XMLHttpRequest();
3 request.open('POST', '/my/url', true);
4 request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
5 request.send(data);

 

/**hide**/
el.style.display = 'none';

 

 1 /**fade in**/
 2 /**javascript**/
 3 <script>
 4     el.classList.add('show');
 5     el.classList.remove('hide');
 6 </script>
 7 <style>
 8     .show {
 9       transition: opacity 400ms;
10     }
11     .hide {
12       opacity: 0;
13     }
14 </style>

 

/**show**/
el.style.display = '';

 

/**add class**/
el.classList.add(className);

 

/**after**/
el.insertAdjacentHTML('afterend', htmlString);

 

/**append**/
parent.appendChild(el);

 

/**before**/
el.insertAdjacentHTML('beforebegin', htmlString);

 

/**clone**/
el.cloneNode(true);

 

/**contains**/
el !== child && el.contains(child);

 

/**children**/
el.children

 

/**Contains Selector**/
el.querySelector(selector) !== null
/**Each**/
var elements = document.querySelectorAll(selector);
Array.prototype.forEach.call(elements, function(el, i){

});
/**Empty**/
el.innerHTML = '';

转载于:https://www.cnblogs.com/qixianchuan/p/11308792.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值