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

  • Home
  • SEARCH
  • 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 7442429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:10:25+00:00 2026-05-29T11:10:25+00:00

The second click function of this script doesn’t work, I think it’s simply a

  • 0

The second “click” function of this script doesn’t work, I think it’s simply a syntax issue. I’m quite new to this. But I need to find a simple way call the live “click” function once for an array of vars.

The script works, just not the second part.

I’m looking for an efficient way to replaceWith an array of different vars, each matching a classed link, and without creating a new function every time.

Any suggestions would be great!

Thanks in advance

<script type="text/javascript">

    $(window).load(function(){

        $('a.pow').live("click",function(e) {

            webgl = $('<iframe src="http://s..."> </iframe>');
            e.preventDefault();     
            $('#slider-wrapper').replaceWith(webgl);
        });

        $('a.biff').live("click",function(e) {

            video = $('<iframe src="http://s..."> </iframe>');
            e.preventDefault();
            $('#slider-wrapper').replaceWith(video);    
        });
    });

</script>

html

<div id="slider-wrapper">
    <div>
        <a class="pow" href="">
        </a>
    </div>
    <div>
        <a class="biff" href="">
        </a>
    </div>

next one could be..

    <div>
        <a class="batman" href="">
        </a>
    </div>
</div><-- close slider wrapper -->
  • 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-05-29T11:10:26+00:00Added an answer on May 29, 2026 at 11:10 am

    You can give all your anchors that will load iframes a common class, move the description of the anchor from class to a custom attribute, and have the event handler to act on the custom attribute instead.

    <div id="slider-wrapper">
        <div>
            <a class="link" href="" data-desc="pow">
            </a>
        <div>
        <div>
            <a class="link" href="" data-desc="biff">
            </a>
        <div>
        <div>
            <a class="link" href="" data-desc="batman">
            </a>
        <div>
    </div>
    

    And in your script:

    <script type="text/javascript">
    
        var desc_url_map = {
            "pow" : "http://s...",
            "biff" : "http://s...",
            "batman" : "http://s..."
        };
    
        $(window).load(function () {
            $('a.link').live('click', function(evt) {
                item = $('<iframe src="' + desc_url_map[this.dataset.desc] + '"></iframe>');
                $('#slider-wrapper').replaceWith(item);
                evt.preventDefault();
            });
        });
    
    </script>
    

    Hope there are no bugs 🙂

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

Sidebar

Related Questions

I'm using this script to switch layouts in a page: $(span.switcher).click(function () { $(span.switcher).toggleClass(swap);
<script type=text/javascript> $(function(){ $('button').each(function(i){ $(this).click(function(){ $(this).after('<br /><button type=button>Button</button>'); }); }); }); </script> <button type=button>Button</button>
This way of prepending does work for me: <script type=text/javascript charset=utf-8> $(document).ready(function() { $(#learn-more-button).click(function()
Why doesn't this code work to turn off setInterval? I click an element to
I found this in another question/answer and modified it... but it still doesn't work.
I've made this snippet that clicks a link after 10th second: function timeout() {
the second function isnt working? $('.edit_hover').live('hover', function(e){ $(this).stop(); var half_width = ($(this).css('width').slice(0, -2))/2; var
I have this piece of code, and it doesn't work as I expect (it's
I am a bit new to Javascript. I am writing this dummy script to
Im just learning javascript and I'm just wondering why this doesn't work. I've created

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.