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 8659491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:01:44+00:00 2026-06-12T16:01:44+00:00

Possible Duplicate: jquery or css selector? select all id’s that start with This code

  • 0

Possible Duplicate:
jquery or css selector? select all id’s that start with

This code changes #idview‘s src attribute on mouse-over of ids 1-3.

$("#id_1, #id_2, #id_3, #etc").mouseover(function(){
    $("#idview").attr("src","id_" + this.id.substr(3,4) + ".jpg");
});

How can I select an ID by “#id_” and then a variable integer? Say for example if there were 1000 images, where it would be impractical to write this out long hand?

It may be something like $("#id_"+*)?

  • 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-12T16:01:46+00:00Added an answer on June 12, 2026 at 4:01 pm

    Use an attribute starts-with selector:

    $("[id^='id_']").mouseover(function () {
        //Do stuff
    });
    

    It would be a little more efficient to clarify the element type before the attribute selector, but it’s not clear from your question exactly what elements you’re trying to select.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: jquery or css selector? select all id’s that start with I need
Possible Duplicate: jQuery $(this) vs this In jquery sometimes I find that within a
Possible Duplicate: Jquery: Selection within a selection Consider this code: var $el = $('<div
Possible Duplicate: How to remove all CSS classes using jQuery? I have the following:
Possible Duplicate: Is there a CSS parent selector? I know this is a shot
Possible Duplicate: How to use javascript variables in jquery selectors This works $('input[name=nickname]').css(...); Now
Possible Duplicate: jquery: select the last 4 items in the list jQuery has the
Possible Duplicate: jquery data selector I have several elements with class 'connection_name'. Each one
Possible Duplicate: jQuery 1.7 - Turning live() into on() Just switching my code from
Possible Duplicate: Remove CSS from a Div using JQuery we can set backgroung-image property

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.