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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:26:47+00:00 2026-06-16T07:26:47+00:00

I need this code to run again after the $(‘.mp3’).show(); is executed. $(‘.mp3’).click(function() {

  • 0

I need this code to run again after the $('.mp3').show(); is executed.

$('.mp3').click(function() {
    $(this).toggle(function() {
        $('object').remove();
        $('.mp3-0').show();
    });
});

$('.mp3-0').click(function() {
    $(this).toggle(function() {
        $('#mp3obj').replaceWith('<object width="0" height="0"> <param name="src" value="musicasite.mp3"> <param name="autoplay" value="false"> <param name="controller" value="true"> <param name="bgcolor" value="#FFFFFF"> <embed src="musicasite.mp3" autostart="false" loop="false" width="0" height="0" controller="true" bgcolor="#FFFFFF"></embed> </object>');
        $('.mp3').show();
    });
});​

What this whole snippet is doing for me is removing a song from the website when the user requests, but if this user wants it back then the music plays again.

But, after the code runs all this long it just stops working.

What I need is: the whole HTML file needs to be set as it was before the button was clicked and the code ran.

—– edit ——

An example can be seen here: http://dev.webtoad.com.br/toquedemagica/2012/
The page is in brazilian portuguese, but if you click on ‘Parar música’ and ‘Tocar música’ you can see what I have achieved so far.

  • 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-16T07:26:48+00:00Added an answer on June 16, 2026 at 7:26 am

    You are making two big mistakes:

    1. You’r not using toggle right. You want to toggle just the button visibility not the button behavior. That should be $(this).toggle() and then the rest of the actions outside of the toggle function. As you are clicking on two different buttons thought, there’s not even much sense in using toggle at all, as it could get you into unexpected show/hide behaviors.

    2. On the .mp3-0 click (the second click) you want to (re-)add the <object> you removed in the previous click back inside the #mp3obj, not replace it. This is why the code only runs 3 click;

    STOP – removes the <object>.

    START – replaces #mp3obj with the <object>.

    STOP – removes the <object> again.

    START – …can’t find #mp3obj to replace with <object> (you replaced it!) – function stops working…

    Try this instead:

    $('.mp3').click(function() {
        $(this).hide();
        $('object').remove();
        $('.mp3-0').show();
    });
    
    $('.mp3-0').click(function() {
        $(this).hide();
        $('#mp3obj').html('<object width="0" height="0"> <param name="src" value="musicasite.mp3"> <param name="autoplay" value="false"> <param name="controller" value="true"> <param name="bgcolor" value="#FFFFFF"> <embed src="musicasite.mp3" autostart="false" loop="false" width="0" height="0" controller="true" bgcolor="#FFFFFF"></embed> </object>');
        $('.mp3').show();
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically my issue comes down to this, I need to run code on a
I need use this code: <%= button_tag :class => btn btn-primary do %> <%=
I have this code and I need to make this work: if ($handle =
I need to change this code to cpp code This is the c# code
I have found this project on Codeplex. http://www.codeplex.com/ProjNET I need to integrate this code
With this code we can create a simple word document but I need to
I need this construction in my HAML code: - if something1 %div.a - elsif
i have this code: def some_method(): #i need to get some attrs :( return
I have this code below. I need to use a class id instead of
I need a quick hand figuring out what this code is doing, and how

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.