themactep

a collection of miscellaneous projects of Paul Philippov

Javascript Useful Tips

$('a[href^="http:"],a[href^="https:"],a[rel^="external"]').attr('target','_blank');

How to delete first parent DIV with given CSS-class (.myclass)

$(this).parents('div.myclass:eq(0)').remove();

How to avoid IE quirks

$('#element').append(new Option(name, value, true, true));

It does not work in IE. Use following code instead:

$('#element').append('<option value="'+value+'">'+name+'</option>');

How to install nodejs

$ curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
$ sudo apt-get install -y nodejs