Last active
February 3, 2018 18:04
-
-
Save nixon1333/2c5756784e173ce396bd34e634bff26f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// similar behavior as an HTTP redirect | |
window.location.replace("http://sidanmor.com"); | |
// similar behavior as clicking on a link | |
window.location.href = "http://sidanmor.com"; | |
//get value of a input item(of a id) using raw js | |
document.getElementById('inputID').value; | |
//get value of a input item(of a name) using raw js | |
document.getElementsByName('inputID')[0].value; | |
//=============== | |
//get an element by class | |
function getElementsByAttributeValue(atrName,atrValue) { | |
var matchElems = []; | |
var allElems = document.getElementsByTagName('*'); | |
for(var x = 0, len = allElems.length; x < len; x++) { | |
if(allElems[x].getAttribute(atrName) != atrValue) { | |
continue; | |
} | |
matchElems.push(allElems[x]); | |
} | |
return matchElems; | |
} | |
var elems = getElementsByAttributeValue("class","someclass"); | |
//=============== | |
//=============== | |
//ajax request | |
$.ajax({ | |
method: "<METHOD NAME>", | |
url: "some.php", | |
data: { name: "John", location: "Boston" } | |
}) | |
.done(function( msg ) { | |
alert( "Data Saved: " + msg ); | |
}); | |
//=============== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment