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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:09:34+00:00 2026-05-23T01:09:34+00:00

jQuery.fn.add = function() { var Bnumber = $(this).find(.B_Add); if (Bnumber) { Bcount = parseInt(Bnumber.html())

  • 0
jQuery.fn.add = function() {

    var Bnumber = $(this).find(".B_Add");

    if (Bnumber) {
        Bcount = parseInt(Bnumber.html()) + 1;
        $(this).find("div.B_Add").remove();
        $(this).parent().find(".B_List").append('<div class="Badge B_Add">'+ Bcount +'</div>');

    } else {
        $(this).find(".B_List").append('<div class="Badge B_Add">1</div>');
    }
}

I have a contextual menu script running, when i click on one of the options, it calls this function. It’s supposed to see if the active element has this badge or not. If it does, it increments the integer value of the badge. Otherwise, it creates the badge starting at 1. The latter part is easy, the former harder.

I think i’m mixing up element types, and i’m not sure how to use parseInt…

EDIT

Figured it out.

jQuery.fn.add = function() {
    if ($(this).find(".Badge").hasClass(".B_add")) {
        bCount = parseInt($(this).find(".B_add").text());
        $(this).find(".B_add").remove();
        $(".OPT .B_list").append('<div class="Badge B_add">'+(bCount+1)+'</div>');
    } else {
        $(".OPT .B_list").append('<div class="Badge B_add">0</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-05-23T01:09:35+00:00Added an answer on May 23, 2026 at 1:09 am

    Try this.

    jQuery.fn.add = function() {
    
        var Bnumber = $(".B_Add");
    
        if (Bnumber) {
            var Bcount = parseInt(Bnumber.html()) + 1;
            Bnumber.html(Bcount);
        } else {
            $(this).find(".B_List").append('<div class="Badge B_Add">1</div>');
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use jQuery to add dynamic Add/Remove row function, but I meet
Is it possible to add a jQuery function so that a click in a
Jquery has a great language construct that looks like this: $(document).ready(function() { $(a).click(function() {
I am loading images externally using jQuery load function.. but not able add light
Here is my jQuery using delegate and ajax: $(.tweets).delegate(#fav #submit, click, function(){ var favid
I am trying to make jquery add new div and then make it draggable
var A = function(x){ var that = this; this.a = x; } A.prototype =
Hi i use the following simple jquery script to append input. Source http://muiomuio.com/web-design/add-remove-items-with-jquery <html
I'm using jQuery to add an additional row to a table as the last
I'm trying to add a new node to an jQuery SimpleTree , but all

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.