Select an a tag with some particular href

Sometimes, you want to not select all a-tags in HTML, but only particular, for instance based on (part of) the url they're pointing to.

That can be done like this:

$('a[href="The_part_youre_searching_for"]')

These are the attributes

= is exactly equal
!= is not equal
^= is starts with
$= is ends with
*= is contains
~= is contains word
|= is starts with prefix (i.e., |= "prefix" matches "prefix-...")

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.