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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:00:28+00:00 2026-06-09T14:00:28+00:00

there will be 14 similar functions and i need to combine it because those

  • 0

there will be 14 similar functions and i need to combine it because those functions interact with each other, help me pls

$(".mieszkanie").click(function() {
        var num = this.id.replace(/c_07_/, "").substr(0, 3);
        $('.pdf').attr({ 
            href: "img/rzuty/mieszkania/pietro07rzuty/" + num + ".pdf"
        });
        $('.karta img').attr({ 
            src: "img/rzuty/mieszkania/pietro07rzuty/" + num + ".png",
            alt: "mieszkanie" + num
        });
    });

$(".mieszkanie").click(function() {
        var num = this.id.replace(/c_10_/, "").substr(0, 3);
        $('.pdf').attr({ 
            href: "img/rzuty/mieszkania/pietro10rzuty/" + num + ".pdf"
        });
        $('.karta img').attr({ 
            src: "img/rzuty/mieszkania/pietro10rzuty/" + num + ".png",
            alt: "mieszkanie" + num
        });
    });

HTML

<div id="div10p" class="okno clearfix rzutyWraper">
        <h2>RZUT 10 PIĘTRA</h2> 
        <div id="rzuty10p" class="rzuty">
            <span id="c_10_248" class="mieszkanie" title=""></span>
            <span id="c_10_247" class="mieszkanie" title=""></span>
            <span id="c_10_249" class="mieszkanie" title=""></span>
            <span id="c_10_250" class="mieszkanie" title=""></span>
            <span id="c_10_252" class="mieszkanie" title=""></span>
            <span id="c_10_251a" class="mieszkanie" title=""></span>
            <span id="c_10_251b" class="mieszkanie" title=""></span>
        </div>      
        <div class="karta">
            <div class="kartaPanel">
                <button class="close">zamknij</button>
                <a class="pdf" href="" onclick="this.target='_blank'">pobierz</a>
            </div>
            <img src="" alt="mieszkanie" />
        </div>
    </div>


    <!-- PIETRO 07 -->
    <div id="div07p" class="okno clearfix rzutyWraper">
        <h2>RZUT 7 PIĘTRA</h2> 
        <div id="rzuty07p" class="rzuty">
            <span id="c_07_001" class="mieszkanie" title=""></span>
            <span id="c_07_002a" class="mieszkanie" title=""></span>
            <span id="c_07_002b" class="mieszkanie" title=""></span>
            <span id="c_07_003" class="mieszkanie" title=""></span>
            <span id="c_07_004" class="mieszkanie" title=""></span>
            <span id="c_07_005" class="mieszkanie" title=""></span>
            <span id="c_07_006a" class="mieszkanie" title=""></span>
            <span id="c_07_006b" class="mieszkanie" title=""></span>
            <span id="c_07_008" class="mieszkanie" title=""></span>
        </div>      
        <div class="karta">
            <div class="kartaPanel">
                <button class="close">zamknij</button>
                <a class="pdf" href="" onclick="this.target='_blank'">pobierz</a>
            </div>
            <img src="" alt="mieszkanie" />
        </div>
    </div>
  • 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-09T14:00:29+00:00Added an answer on June 9, 2026 at 2:00 pm

    Check this regexp.

    /.+_(\d+)_(.+)/.exec('c_10_249');
    

    result will be

    ["c_10_249", "10", "249"]
    

    And then only one callback for each elements having ‘mieszkanie’ class.

    $(".mieszkanie").click(function() {
        var nums =  /._(\d+)_(.+)/.exec( this.id );
            var num2 = nums[2].substr(0, 3);
        $('.pdf').attr({ 
            href: "img/rzuty/mieszkania/pietro"+nums[1]+"rzuty/" + num2 + ".pdf"
        });
        $('.karta img').attr({ 
            src: "img/rzuty/mieszkania/pietro"+nums[1]+"rzuty/" + num2 + ".png",
            alt: "mieszkanie " + num2
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a standard C function similar to strtol which will take a char*
Is there a third party tool or something similar that will allow users to
Are there any services similar to codepad that will allow you to test Perl
Is there a way to create a window (similar to a screen-saver) that will
I realize that there are other posts asking similar questions, but do not quite
There is a button, when i click that there will be a call to
There will be a thumbnail as a left float, followed by the title and
Or there will be some conflicts ?
I will have a screen in which there will be 11 images one below
I guess there will be a very simple answer to this. But here goes.

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.