Category Archives: JQuery

Get URL Query String with jQuery

To get query string value in an url, for example to get ‘user_id’ value from an url

http://getquerystringparams.com?user_id=123456&msg_id=56

 

How to check if jQuery is loaded and what version?

To check if the Jquery is loaded or not and version of the loaded Jquery, use following code snippet( found it on stackoverflow)

 

Get the text of selected option in JQuery

To get the text of selected option of a dropdown in Jquery,

For example following is the dropdown containing  cities

to get the text of the selected option, in JQuery

 

Convert latitude and longitude from decimal to Deg and vice versa in Jquery

Following code snippet will convert decimal latitude and longitude into degree, min and sec

To convert a latitude and longitude in degree min sec to decimal

 

Set,Read & Delete Cookie in Jquery

Recently in one of my project, I happened to use Cookie in Jquery. So, I though it would helpful for future references and to others also.

To set, read and delete cookie in Jquery I found this plugin very useful, you can download this from here,

http://plugins.jquery.com/cookie/

First include this plugin on your page by

To set a cookie

first parameter is the name of the cookie, which we will use further to read / delete, second parameter is the value for this cookie.

If we want a cookie to get expire after a time interval, we do this by setting time limit

Now this cookie will get expired after 5 days.

To read a cookie’s value, just pass the cookie name

To delete a cookie

Open link in new tab using jquery

To open a link in new tab, using Jquery, use window.open and pass the url

 

Get current page title, url and meta description using JQuery

To get the title of current page, there is a one line of JQuery code

To read the meta description of current, use following code

To get the url of current page