// Различные полезные сниппеты js
// Получить доступ к dom в iframe
var iframe = document.getElementById('mainFrame');
iframe.onload = function() {
var iframeDoc = iframe.contentWindow.document;
var divIframe = $(iframeDoc).contents().find('div');
}
// аналог isset
if ( typeof variable !== "undefined") {
// vriable is set and isnt falsish so it can be used;
}
// удалить класс по маске (jquery плагин)
(function($) {
$('div').removeClassWild('myclass_*');
$.fn.removeClassWild = function(mask) {
return this.removeClass(function(index, cls) {
var re = mask.replace(/\*/g, '\\S+');
return (cls.match(new RegExp('\\b' + re + '', 'g')) || []).join(' ');
});
};
})(jQuery);