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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:09:53+00:00 2026-05-26T06:09:53+00:00

$(function() { var jw; jw = Player; return $(‘.btn-control:not(.add-btn)’).toggle(function() { var mnetInfo; mnetInfo =

  • 0
$(function() {
  var jw;
  jw = Player;
  return $('.btn-control:not(.add-btn)').toggle(function() {
    var mnetInfo;
    mnetInfo = {
      albumId: $(this).data('album-id'),
      trackId: $(this).data('song-id')
    };
    if (jwplayer() !== void 0 && $(this).hasClass('current')) {
      jw.play();
    } else {
      jw.get(mnetInfo);
      $(document.body).find('a[class*="pause"]').removeClass('pause').addClass('play');
      $(document.body).find('td.bold').removeClass('bold');
      $(document.body).find('.current').removeClass('current');
      if ($(document.body).find($(this)).parentsUntil('table').length > 0) {
        $(document.body).find('tr#' + mnetInfo.trackId + ' td.song_info').addClass('bold');
      }
    }
    $(this).removeClass('play').addClass('pause current');
    console.log("FIRST");
    return false;
  }, function() {
    jw.pause();
    $(this).removeClass('pause').addClass('play');
    console.log("SECOND");
    return false;
  });
});

The above code works with interacting with my implementation of jwPlayer() and works fine for the first two clicks (click play on the first album it begins to play, click play on second album the second album begins to play, but if you click play on another album the function triggers the pause toggle instead of firing the play toggle)… hope that makes sense

Working Code:

 $(function() {
  var jw;
  jw = Player;
  $('.play').live("click", function() {
    var mnetInfo;
    mnetInfo = {
      albumId: $(this).data('album-id'),
      trackId: $(this).data('song-id')
    };
    if (jwplayer() !== void 0 && $(this).hasClass('current')) {
      jw.play();
    } else {
      jw.get(mnetInfo);
      $('a[class*="pause"]').removeClass('pause').addClass('play');
      $('td.bold').removeClass('bold');
      $('.current').removeClass('current');
      if ($(this).parentsUntil('table').length > 0) {
        $('tr#' + mnetInfo.trackId + ' td.song_info').addClass('bold');
      }
    }
    $(this).removeClass('play').addClass('pause current');
    return false;
  });
  return $('.pause').live("click", function() {
    jw.pause();
    $(this).removeClass('pause').addClass('play');
    return false;
  });
});
  • 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-26T06:09:53+00:00Added an answer on May 26, 2026 at 6:09 am

    Toggle keeps it’s state to a specific element. So, it will only alternate between the two callbacks when called on the same element in successive calls. If you want to toggle between successive functions no matter which element is clicked on, then you will have to keep your own state and alternate between the pause/play yourself or always call toggle(fn1, fn2) on the same element.


    You also should learn how to simplify your use of jQuery. For example, this code:

      $(document.body).find('a[class*="pause"]').removeClass('pause').addClass('play');
      $(document.body).find('td.bold').removeClass('bold');
      $(document.body).find('.current').removeClass('current');
      if ($(document.body).find($(this)).parentsUntil('table').length > 0) {
        $(document.body).find('tr#' + mnetInfo.trackId + ' td.song_info').addClass('bold');
      }
    

    should be:

      $('a[class*="pause"]').removeClass('pause').addClass('play');
      $('td.bold').removeClass('bold');
      $('.current').removeClass('current');
      if ($(this).parentsUntil('table').length > 0) {
        $('tr#' + mnetInfo.trackId + ' td.song_info').addClass('bold');
      }
    

    You do not start every selector with $(document.body).find().

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

Sidebar

Related Questions

function Player() { var score; this.getScore = function() { return score; } this.setScore =
var Dog = function() { var _instance = 'hello world'; return function() { console.log(this._instance);
$(a.close).click(function() { var id = $(this).attr(id); alert(id); $(this).parents(div.venue:first).fadeOut(Fast); return false; }); Any ideas why
For example: (function() { var proxied = window.eval; window.eval = function() { return proxied.apply(this,
$(.delete).click( function() { var thesender = this; $(thesender).text(Del...); $.getJSON(ajax.php, {}, function(data) { if (data[result])
$('#types').change(function() { var htmlToAppend = <br/><input id='btnAddDictionary' type='button' value='Add Dictionary' />; if ($(#types).val() ==
$(.sectionHeader).click(function() { var row = $(this).parent(); while (row.next().length != 0) { row = row.next();
$(function(){ $('a').each(function(){ var x=this.href; this.href=www.somesitename.com/filter+this.href; }); }); i wrote the above jQuery script to
I have a class: function RustEditor() { this.init = function() { var saveButton =
Revised Code jQuery(function($) { $(#filter).keyup(function () { var filter = $(this).val(), count = 0;

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.