vcavalcante@lambda3.com.br @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
function getElementsByClass(searchClass,node) {
if ( node == null )
node = document;
var classElements = [],
els = node.getElementsByTagName("*"),
elsLen = els.length,
pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"), i, j;
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
Victor Cavalcante @vcavalcante
$(".muitoSimples")
Victor Cavalcante @vcavalcante
if (redButton.addEventListener) { // all browsers and IE>=9
redButton.addEventListener ("click", OnRedClick, false);
}
else {
if (redButton.attachEvent) { // IE before version 9
redButton.attachEvent ('onclick', OnRedClick);
}
}
Victor Cavalcante @vcavalcante
$("#redButton").click(onRedClick)
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
by @ElijahManor
Victor Cavalcante @vcavalcante
by @ElijahManor
Victor Cavalcante @vcavalcante
$("#datepicker");
$("input");
$(".date");
$("input.date");
Victor Cavalcante @vcavalcante
$("#eventos");
document.getElementById("eventos");
$("form");
document.getElementsByTagName("form")
$(".data");
document.getElementsByClassName("data");
$("input.cpf");
document.querySelectorAll("input.cpf"); //Nodelist
document.querySelector("div.cpf"); //FirstElement
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
$("span.nome").each(function(index, element) {
$(element).text("Olá: "+ index);
});
Victor Cavalcante @vcavalcante
//jquery
$("span.nome").each(function(index, element) {
$(element).text("Olá: "+ index);
});
//nativo
var nodeList = document.querySelectorAll("span.nome");
var i;
for(i= 0, len= nodeList.length; i< len; ++i) {
nodeList[i].innerText= "Hello: "+ i;
};
Victor Cavalcante @vcavalcante
//jquery
$("span.nome").each(function(index, element) {
$(element).text("Olá: "+ index);
});
//nativo
var nodeList = document.querySelectorAll("span.nome"),
elems= Array.prototype.slice.call(nodeList);
elems.forEach(function(element, index) {
element.innerText= "Olá: "+ index;
});
Victor Cavalcante @vcavalcante
//jquery
$("span.nome").each(function(index, element) {
$(element).text("Olá: "+ index);
});
//nativo
function $t(selector) {
return [].slice.call(document.querySelectorAll(selector));
}
$t("span.nome").forEach(function(element, index) {
element.innerText= "Olá: "+ index;
});
Victor Cavalcante @vcavalcante
var xhr= new XMLHttpRequest();
xhr.open("POST", "/caminho/json/", true);
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xhr.onload= function() {
if(this.status=== 200) { alert(this.responseText); }
};
xhr.send("category=books&sort=asc");
Victor Cavalcante @vcavalcante
var formData= new FormData(), xhr= new XMLHttpRequest();
formData.append("category", "books");
formData.append("sort", "asc");
xhr.open("POST", "/caminho/json/", true);
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xhr.onload= function() {
if(this.status=== 200) { alert(this.responseText); }
};
xhr.send(formData);
Victor Cavalcante @vcavalcante
var form = document.getElementById("myForm");
var formData= newFormData(form);
var xhr= newXMLHttpRequest();
xhr.open("POST", "/caminho/json/", true);
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xhr.onload= function() {
if(this.status=== 200) { alert(this.responseText); }
};
xhr.send(formData);
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Ajax
Animação
Extenção
Elementos
Encontre Elementos
Eventos
Victor Cavalcante @vcavalcante
Dá para ser menor!
Victor Cavalcante @vcavalcante
> git clone git://github.com/jquery/jquery.git
>
> npm install -g grunt-cli bower
>
> grunt -version && bower -version
>
> cd jquery&& npm install
>
> grunt
>
> grunt custom:-sizzle,-ajax,-css,-deprecated
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
victor@cavalcante.net