Javascript - mwicat/personal GitHub Wiki
Entries.prototype.select = function (
{ from = 0, to = this.length } = {}) {
console.log(from);
};
entry.select({ from: 0 });
javascript:(function() {
function l(u, i) {
var d = document;
if (!d.getElementById(i)) {
var s = d.createElement('script');
s.src = u;
s.id = i;
d.body.appendChild(s);
}
}
l('//code.jquery.com/jquery-3.3.1.min.js', 'jquery')
})();
jQuery.fn.jquery
$.map($("select#product option"), function(a) { return $(a).attr("value") } )
$.extend(d[0].dataset, {'a': 13, 'b': 14})
$.each(arr, function(index, value) {
alert( index + ": " + value );
});
$.each(obj, function(key, value) {
alert(key + ": " + value ;
});
vim:
:%!python -m json.tool
Access-Control-Allow-Origin: <origin> | *
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<div id="scale"></div>
<script>
function addScaleButton(num) {
var clsname = 'scale' + num;
$('<a />', {
text : num,
'class' : clsname
}).appendTo('#scale');
$("#scale").find('.' + clsname).button().click(function() {
alert('hello' + num);
});
}
$(function() {
for (var i = 1; i <= 8; i++) {
addScaleButton(i);
}
});
</script>
##Read synchronously
function read_sync(url) {
var req = new XMLHttpRequest();
var filename = url;
req.open('GET', filename, false);
req.send(null);
if (req.status != 0) {
throw "Cannot open " + filename;
}
var xmldoc = req.responseXML;
return xmldoc;
}
$('select[name=advertiser]').val()
$('select[name=advertiser] option:selected')
$('select[name=advertiser] option:selected').map(function() { return $(this).attr('value') })
$('select[name=advertiser] option:not(:selected)').map(function() { return $(this).attr('value') })
$('select[name=advertiser] option').attr('selected','selected');
$('select[name=advertiser] option').attr('selected', '');
$('select[name=advertiser] option[value=1925]').attr('selected', '')
arr.forEach(function (build) {
});
$('[name=resource_type]').find(":selected").val()
var timestamp = moment.unix(1293683278);
var time_str = timestamp.format("DD-MM-YYYY HH:mm:ss");