Friday, 12 December 2008

Profiler for .NET

A good profiler tool... not free but you can download and evaluate
http://www.jetbrains.com/profiler/

Monday, 1 December 2008

JQuery - Count Paragraphs

Add following click handlers to page using console in FireBug
  • $('#NoOfParagraphs').click(showNoOfParagraphs)

Example taken from here docs.jquery.com

..1..

"The quick brown fox jumps over the lazy dog" is a pangram (a phrase that contains all of the letters of the alphabet). It has been used to test typewriters and computer keyboards, and in other applications involving all of the letters in the English alphabet, because it is also a short coherent sentence.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into....

..4..



function showNoOfParagraphs(e) 
{
  $('#NoOfParagraphs').click(function() {
  $("div.FadeAndAnimation p.ParagraphResults").append("   Paragraph Count :-" +
$("div.FadeAndAnimation p").size() + "
"); }

JQuery - Basic Show and Hide

Add following click handlers to page using console in FireBug
  • $('#hideh1').click(function() {$("div[class='titlewrapper']").hide();});
  • $('#showh1').click(function() {$("div[class='titlewrapper']").show();});
  • $('#toggleh1').click(function(){$("div[class='titlewrapper']").toggle();});

Example taken from here... docs.jquery.com


Use the following buttons to show and hide this blogs title.

Sunday, 30 November 2008

JQuery Predicates - Attribute contains

Add following click handlers to page using console in FireBug
  • $("#lnkRedAttributeContains").click(showRedContains);
  • $("#lnkYellowAttributeContains").click(showYellowContains);
To find an element with an id of 'HelloGoodbyeAttributeContains'
click me yellow
click me red

The click me red also finds the two links as their ids match the predicate. The click me yellow is specifically looking for div elements therefore the two links are not turned yellow.


JQuery Predicate, attribute Contains
$("[ @id *= 'ributeCont' ]").removeClass("YellowAttributeContains").addClass("RedAttributeContains"); 
$("div[ @id *= 'ributeCont']").removeClass("RedAttributeContains").addClass("YellowAttributeContains"); 

JQuery Predicates - Attribute ends with

Add following click handlers to page using console in FireBug
  • $("#lnkRedAttributeEndsWith").click(showRedEndsWith);
  • $("#lnkYellowAttributeEndsWith").click(showYellowEndsWith);
To find an element with an id of 'HelloGoodbyeAttributeEndsWith'
click me yellow
click me red

The click me red also finds the two links as their ids match the predicate. The click me yellow is specifically looking for div elements therefore the two links are not turned yellow.


JQuery Predicate, attribute Ends With
$("[id$='teEndsWith']").removeClass("YellowAttributeEndsWith").addClass("RedAttributeEndsWith"); 

or

$("div[id$='teEndsWith']").removeClass("RedAttributeEndsWith").addClass("YellowAttributeEndsWith"); 

JQuery Predicates - Attribute starts with

Add following click handlers to page using console in FireBug
  • $("#lnkRedAttributeStartsWith").click(showRedStartsWith);
  • $("#lnkYellowAttributeStartsWith").click(showYellowStartsWith);
To find an element with an id of 'HelloGoodbyeAttributeStartsWith'
click me yellow
click me red
JQuery Predicate, attribute Starts With


$("[id ^= 'HelloGoodbyeAttributeSt']")
    .removeClass("YellowAttributeStartsWith")
    .addClass("RedAttributeStartsWith"); 

  or

$("div[id^='HelloGoodbyeAttributeSt']")
    .removeClass("RedAttributeStartsWith")
    .addClass("YellowAttributeStartsWith"); 

JQuery Predicates - Attribute equals

This example uses JQuery attribute selector to add or remove a css class from an html element. Add following click handlers to page using console in FireBug
  • $("#lnkRedAttributeEquals").click(showRed)
  • $("#lnkYellowAttributeEquals").click(showYellow);
This is an html div element with an id="HelloGoodbyeAttributeEquals"

 

JQuery Predicate, id attribute equals
$("#HelloGoodbyeAttributeEquals").removeClass("YellowAttributeEquals").addClass("RedAttributeEquals"); 

or another syntax for an id attribute equals

$("[id='HelloGoodbyeAttributeEquals']").removeClass("YellowAttributeEquals").addClass("RedAttributeEquals"); 

or a div tag with an id equals

$("div[id='HelloGoodbyeAttributeEquals']").removeClass("YellowAttributeEquals").addClass("RedAttributeEquals"); 

function showRed(e) {
    e.preventDefault();
    $("[id='HelloGoodbyeAttributeEquals']").removeClass("YellowAttributeEquals")
                                           .addClass("RedAttributeEquals");
}

function showYellow(e) {
    e.preventDefault();
    $("#HelloGoodbyeAttributeEquals").removeClass("RedAttributeEquals")
                                     .addClass("YellowAttributeEquals"); 
}