Scripting Stylesheets


			
			$(function(){
				
				function selectStylesheetByTitle(title){
					for(var i=0; i< document.styleSheets.length; i++){
						var thisStylesheet = document.styleSheets[i];
						var thisTitle = document.styleSheets[i].title;
						if(thisTitle.toLowerCase() == title.toLowerCase()){
							alert('found it: '+ i);
							return document.styleSheets[i];
						}
					}
				}
				
				//selectStylesheetByTitle('main');
				
				
/*
				function selectRuleBySelector(sel){
					var stylesheet;
					if(document.styleSheets[1].cssRules){
						theRules = document.styleSheets[1].cssRules;
					}else if(document.styleSheets[1].rules){
						theRules = document.styleSheets[1].rules
					}
					for(){
						
					}
				}
*/
				
				
				
				
				var theRules = new Array();
				console.log(document.styleSheets);
				
				setTimeout(function(){
					console.log(document.styleSheets[0].rules[0].cssText);
					try{
						            document.styleSheets[0].rules[0].style.color = 'green';
						console.log(document.styleSheets[0].rules[0].cssText);
					}catch(e){
						alert('oop!: '+ e.message);
					}
				}, 2000);
				
				if (document.styleSheets[1].cssRules){
					// Safari
					theRules = document.styleSheets[1].cssRules;
					console.log(theRules);
					for(var i=0; i
	

Load page dynamically in jQTouch

	
                // Page animations end with AJAX callback event, example 1 (load remote HTML only first time)
                $('#callback').bind('pageAnimationEnd', function(e, info){
                    if (!$(this).data('loaded')) {                      // Make sure the data hasn't already been loaded (we'll set 'loaded' to true a couple lines further down)
                        $(this).append($('
Loading
'). // Append a placeholder in case the remote HTML takes its sweet time making it back load('ajax.html .info', function() { // Overwrite the "Loading" placeholder text with the remote HTML $(this).parent().data('loaded', true); // Set the 'loaded' var to true so we know not to re-load the HTML next time the #callback div animation ends })); } });