jQuery: Select links that do not contain a period.

Posted on 2013-06-07
Last Modified: 2013-06-07
Using jQuery, how can I add a condition so that this is not matched if the link contains a period?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<script type="text/javascript" src=""></script>
<script type="text/javascript">

$(document).ready(function() {

    $('a[href]').each(function () {

    $('a[href]').not('[href^="http"],[href^="mailto:"],[href^="/"],[href^="#"]').each(function () {





<a href="#hello">Yellow</a>
<a href="world">Red</a>
<a href="">Yellow</a>
<a href="/">Yellow</a>
<a href="test.html">Yellow</a>



Open in new window

Question by:hankknight
LVL 82

Accepted Solution

leakim971 earned 400 total points
ID: 39229144

Assisted Solution

by:Ishaan Rawat
Ishaan Rawat earned 100 total points
ID: 39229155
Try this...

$("a[href*="."]").each(function() {
     // do as your wish with the a elements having . in their href...

Open in new window

or if you just want to add CSS... then you can do that by CSS to..

     // do as your wish with the a elements having . in their href...

Open in new window


Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now