jquery selector code example

Example 1: select a form by name jquery

var frm = $('form[name="frmSave"]');

Example 2: jquery selector this and class

$(".class").click(function(){
     $(this).find(".subclass").css("visibility","visible");
});

Example 3: jquery class selector

$('.class').jquery_function();

Example 4: jquery find tag and class

$(".txtClass")                  =>  getElementsByClassName()

$("#childDiv2 .txtClass")       =>  getElementById(),
                                    then getElementsByClassName()

$("#childDiv2 > .txtClass")     =>  getElementById(),
                                    then iterate over children and check class

$("input.txtClass")             =>  getElementsByTagName(),
                                    then iterate over results and check class

$("#childDiv2 input.txtClass")  =>  getElementById(),
                                    then getElementsByTagName(),
                                    then iterate over results and check class

Example 5: jquery or selector

$( "div, span, p.myClass" ).css( "border", "3px solid red" );

Example 6: jquery select

$('#selector').selectmenu();

Tags: