Skip to content

Instantly share code, notes, and snippets.

View tsevdos's full-sized avatar
🏠
Working from home

John Tsevdos tsevdos

🏠
Working from home
View GitHub Profile
@tsevdos
tsevdos / context1.js
Created January 2, 2012 09:26
jQuery tips: Specify a context
$('h1', 'div#posts'); //using jQuery wrapper as context
@tsevdos
tsevdos / chaining1.js
Created January 2, 2012 09:36
jQuery tips: Chaining
$('<div id="test"><p><a>John</a></p></div>').find('a').attr('href' , 'http://phrappe.com/').end().appendTo('body');
@tsevdos
tsevdos / content-based-selection.js
Created January 2, 2012 09:40
jQuery tips: Select elements based on their content
<p>Hello World!</p> // Markup $('p:contains("Hello")');
@tsevdos
tsevdos / replace-dom-elements.js
Created January 2, 2012 09:42
jQuery tips: Replace DOM elements
$('li.old').replaceWith('<li>new li</li>');
@tsevdos
tsevdos / example1.js
Created January 2, 2012 10:02
Creating an element in jQuery 1.4
$('<div/>', {
id: 'feature',
class: 'post',
css: {
border : '1px solid red',
padding : '5px'
},
html: '<p>This is a featured <strong>super</strong> post</p>',
click: function() {
alert('You click the featured post!')
@tsevdos
tsevdos / jquery-object-to-dom-object1.js
Created January 2, 2012 12:07
Convert a jQuery object to raw DOM object
var myDiv= $('div')[1]; // myDiv is a raw DOM object
alert(myDiv.innerHTML) // and we can do all the normal things with it
@tsevdos
tsevdos / beginning-ordered-lists-with-numbers-other-than-1.html
Created January 2, 2012 12:33
Beginning HTML ordered lists with numbers other than 1
<ol start="4">
<li>list item 1</li>
<li>list item 2</li>
<li>list item 3</li>
<li>list item 4</li>
<li>list item 5</li>
</ol>
@tsevdos
tsevdos / apple-icon-1.html
Created January 2, 2012 15:26
How to attach a custom apple iPhone/iPad icon to your website
<link rel="apple-touch-icon" href="/images/mycustomiphoneicon.png" />
@tsevdos
tsevdos / jquery.equalHeights.js
Created January 2, 2012 15:29
jQuery "equal heights" method
$.fn.equalHeights = function() {
var maxHeight = 0;
$(this).each(function(index){
var height = $(this).height();
if (maxHeight < height) {
maxHeight = height
}
});
$(this).height(maxHeight);
@tsevdos
tsevdos / bookmarklet1.html
Created January 2, 2012 15:32
Bookmarklet
<a href="javascript:alert("Phrappe.com rocks!")>A vary basic bookmarklet!</a>