You have to use
function of jQuery.
Check this jQuery API link
] for demos.
Just try to add your logic and use this function.
And let me know whether you complete it or not.
Please post your test codes and logic using
, so that I can help you. :)