Skip to main content

Posts

Showing posts with the label Jquery

Jquery Tips and Tricks

Attribute selectors in Jquery We access page elements using Class and Id selectors most of the times but at times we need to fetch elements like, access all elements where class name starts with 'form-controls' or class name contains 'form-controls' $('[class^=form-controls]') // class name Begins with "form-controls" $('[class*=form-controls]') // class name Contains "form-controls" $('[class$=form-controls]') // class name Ends with "form-controls" Add new class to existing elements .addClass(className) This will add specified class(es) to the element. This will not replace the existing class(es), rather it will append new class to the existing ones. $( "table" ).addClass( "datatable stripped" ); This will add "datatable" and "stripped" class to all tables Common mistake while using addClass $('#pdOrder').addClass('.datatable'); //This is wrong...

Keyboard driven menu in Jquery

I had a requirement to operate menu with keyboard just like we do in windows application. Traverse through menus using left/ right arrow keys, up/ down arrow keys should work as well. Further user should be able to navigate when Enter key is pressed. I was not able to find any jquery plugin to use for this purpose until I got this one,  https://hanshillen.github.io/jqtest/#goto_menubar This is what exactly I was looking, thanks a ton to the author. But later I realized it is not that easy to get just menu out of this. So I need to play with it and finally got it working. I am sharing code here so that if anyone ever need such type of menu it will be a quick one. This functionality is created by original author @Hans Hillen , I am just providing this code for simplicity. Download @  http://jmp.sh/Z3AtfVv