As I said before , selectors makes jquery powerful . In this post I want to write about attribute selector.
Its very easy ... here is a sample :
Its very easy ... here is a sample :
$("a[href='http://www.google.com']").
In this example $("a") select each link on the page , and [href='http://www.google.com'] restrict the selector to 'a' tags with href attribute equals to 'http://www.google.com' .
example :
I have a list of some files like below
If you want to show this list with appropriate icon for each type of file , you must add an img tag before each link . jquery has .before() and .after() method for insert content after and before selected tag(s) by selector.
In this example $("a") select each link on the page , and [href='http://www.google.com'] restrict the selector to 'a' tags with href attribute equals to 'http://www.google.com' .
example :
I have a list of some files like below
If you want to show this list with appropriate icon for each type of file , you must add an img tag before each link . jquery has .before() and .after() method for insert content after and before selected tag(s) by selector.
Ok . Now I want to select each link in the page with href attribute ends with '.pdf' and insert an img tag befor using .before() method.
and now lets finish it ...
HTML result :