Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8357039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:21:42+00:00 2026-06-09T10:21:42+00:00

I have the following jQuery selector: $(a[href^=’http://’],a[href^=’https://’]); Is it possible to change this so

  • 0

I have the following jQuery selector:

$("a[href^='http://'],a[href^='https://']");

Is it possible to change this so that I don’t need to specify a[href^= twice?

For example, something like:

$("a[href^='http://'||'https://']");

EDIT: My example of http and https should not be taken literally. I could be looking for values starting with y and z instead.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:21:44+00:00Added an answer on June 9, 2026 at 10:21 am

    Quite simple if you’re willing to use a second function call:

    $('a').filter('[href^="http://"],[href^="https://"]');
    

    Or with tokens:

    var startsWith = ['http://', 'https://'];
    $('a').filter(function () {
        var i;
        for (i = 0; i < startsWith.length; i++) {
            if ($(this).is('[href^="' + startsWith[i] + '"]')) {
                return true;
            }
        }
        return false;
    });
    

    Or with a custom expression:

    $.expr[':']​​​​​​.hrefStartsWith = function (ele, i, info) {
        var tokens;
        tokens = info[3].split(',');
        for (i = 0; i < tokens.length; i++) {
            if ($(ele).is('[href^="' + tokens[i] + '"]')) {
                return true;
            }
        }
        return false;
    };
    

    Which would be used as:

    $('a:hrefStartsWith(http://,https://)')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jquery script: $(function(){ $('#top-menu').on('click', 'a.change-menu', function(e){ e.preventDefault() $(#menu-change-div).load($(this).attr(href)); }); });
I have a jQuery selector with following syntax: $('input[type=image]').not('.xyzClass').click(function{ //some functionality }); So this
I have a jQuery selector like the following: $('.someClass div div .specificChildClass:nth-child(even)').addClass('alternateLine'); This stripes
I have the following jquery function that submits to an iframe. The message sent
I have the following jQuery $.ajax({ type: GET, url: http://f.cl.ly/items/0i1V1L1k2F440L1m2Y0G/pointdata.xml, dataType: xml, success: parseXml
I have this following jquery text fly-in animation.Here is my code before I explain
I have the following Jquery that returns values from a dialog Box and fills
Just a quick question... I currently have the following jQuery code with a selector
I have the following structure below. Using jQuery I need to take each link
I have the following JQuery code that processes a GET request upon page load:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.