Skip to content

Instantly share code, notes, and snippets.

@ederrafo
Last active January 1, 2017 03:42
Show Gist options
  • Save ederrafo/c682b3a4aeb1cbd3ba83 to your computer and use it in GitHub Desktop.
Save ederrafo/c682b3a4aeb1cbd3ba83 to your computer and use it in GitHub Desktop.
jquery javascript
/*Check jQuery is defined*/
> typeof jQuery
> window.jQuery
/********************************************
* jquery ajax progressbar
********************************************/
function GetProgress() {
$.ajax({
url: "percentage.php",
success: function (result) {
console.log(result);
var pers = result;
$("#progressbar").progressbar("value", pers.value);
if (pers.value > 0) {
isDone = true;
} else {
setTimeout(GetProgress, 2000);
}
}
});
};
jQuery(function () {
//initialize the plugin
$("#progressbar").progressbar();
GetProgress();
})
/***************************************************************
* How to select the first element in the dropdown using jquery?
***************************************************************/
$('select#cities option:first-child').attr("selected", "selected");
var myDDL = $('myID');
myDDL[0].selectedIndex = 0;
$("#cities").val($("#cities option:first").val());
$("#target")[0].selectedIndex = 0;
/********************************************
* Selectbox reset
********************************************/
$("#target").prop("selectedIndex", 0);
/* Work in chrome, firefox */
$("#cities").val(null);
/* Recorrer un li */
$( "#secondary > ul > li" ).each(function( index ) {
if($( this ).children().length == 0) {
$(this).remove();
}
});
/*
http://www.456bereastreet.com/archive/200704/how_to_prevent_html_tables_from_becoming_too_wide/
http://api.jquery.com/category/selectors/
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment