Tag Archives: JQuery

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

 

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

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