clean way to open a popup window
1 $('a.popup').live('click', function(){ 2 newwindow=window.open($(this).attr('href'),'','height=200,width=150'); 3 if (window.focus) {newwindow.focus()} 4 return false; 5 });
1 $('a.popup').live('click', function(){ 2 newwindow=window.open($(this).attr('href'),'','height=200,width=150'); 3 if (window.focus) {newwindow.focus()} 4 return false; 5 });
http://docs.jQuery.com/DOM/Traversing/Selectors
1 $('h1') // elementos h1 2 $('#meuID') // elementos com id "meuID" 3 $('.minhaClasse') // elementos definidos com a classe "minhaClasse" 4 $('[width]') // elementos que possuem o atributo width definido 5 $('[width=500]') // elementos que possuem o atributo width definido como 500 6 $('img[width=300]') // imagens que possuem largura = 300 7 $('img[src$=png]') // imagens com final png 8 $('a[href^=http://localhost]') // links que comecem com http://localhost 9 $('a[href$=pdf]') // links com final pdf 10 $('a[href*=www]') // links que contém www 11 $(':empty') // elementos vazio 12 $('div:empty') // elementos div vazios 13 $(':has(p)') // todos elementos que tenham um parágrafo 14 $('div:has(a)'); // elementos div que possuem link 15 $("p:contains('dinei')") // parágrafos que contém a palavra "dinei" 16 $("p:eq(0)") // seleciona o primeiro elemento p
1 function copyToClipBoard(id) { 2 Copied = document.getElementById('id').innerText.createTextRange(); 3 Copied.execCommand("Copy"); 4 }
1 <a href="#top" onclick="$('html, body').animate({scrollTop:0}, 'slow'); return false;">top</a>
http://www.quirksmode.org/js/popup.html
1 function popup(url) { 2 newWindow = window.open(url, 'name', 'height=400,width=335,scrollbars=yes'); 3 if (window.focus) { newWindow.focus() } 4 return false; 5 } 6 7 // <a href="link.html" onclick="popup('link.html');">Link</a>
1 $(document).ready(function() { 2 $('dd').toggle(); 3 $('dt').click(function() {$(this).next('dd').toggle('slideDown');}); 4 });
1 /* IE6 - pseudo class :hover */ 2 $(document).ready(function(){ 3 if(jQuery.browser.msie && jQuery.browser.version<7){ 4 $('[class*="bla"]').hover( 5 function () { 6 $(this).addClass('hover'); 7 }, 8 function () { 9 $(this).removeClass('hover'); 10 } 11 ); 12 } 13 });
http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
1 (function ($) { 2 // VERTICALLY ALIGN FUNCTION 3 $.fn.vAlign = function() { 4 return this.each(function(i){ 5 var ah = $(this).height(); 6 var ph = $(this).parent().height(); 7 var mh = (ph - ah) / 2; 8 $(this).css('margin-top', mh); 9 }); 10 }; 11 })(jQuery); 12 13 // $('#mydiv').vAlign();
from: http://www.position-absolute.com/articles/jquery-fade-and-slide-toggle-plugin/
1 jQuery.fn.fadeSliderToggle = function(settings) { 2 settings = jQuery.extend({ 3 speed:500, 4 easing : "swing" 5 }, settings) 6 7 caller = this 8 if($(caller).css("display") == "none"){ 9 $(caller).animate({ 10 opacity: 1, 11 height: 'toggle' 12 }, settings.speed, settings.easing); 13 }else{ 14 $(caller).animate({ 15 opacity: 0, 16 height: 'toggle' 17 }, settings.speed, settings.easing); 18 } 19 }; 20 21 // use: $('#my_div').fadeSliderToggle();
1 $(document).ready(function() { jQuery.fn.each( function(i) { console.log(i); }); });