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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:32:30+00:00 2026-05-17T21:32:30+00:00

I have a href link is as below <a href=# class=add_encounter>Add</a> on $(document).ready i

  • 0

I have a href link is as below

<a href="#" class="add_encounter">Add</a>

on $(document).ready i run this function is as below

$('.add_encounter').click(function(event) {
    add_encounter(encounters); 
    event.preventDefault();
});

on add_encounter function i changed class name of ahref from add_encounter to encounter encounterSubmitter and wants to click that same to run other function but when i click the
link it runs the function and change the classname to encounterSubmitter and change back to same class i.e. add_enounter

function add_encounter(encounters) {
     if ($('.add_encounter').text() == "Add"){        
        $('.add_encounter').removeClass().addClass("encounterSubmitter")
     } 
    $('.encounterSubmitter').click(function(event) {save(); event.preventDefault();}); 
}

save function is as below

  function save() {
    var encounter = $('#name').val();
    var key = $('#encounterKey').val();
    if (key == '') {
      key = null
    }
   if (encounter == ''){
 cancel_encounter() 
   }
}

cancel_encounter is as below

function cancel_encounter() {     
        $('.encounterSubmitter').removeClass().addClass("add_encounter")
        $('.add_encounter').text("Add")         
}

So it goes to save function checks the if condition and goes to cancel_encounter function
and changes the classname back to add_encounter

I know this question is little confusing, i hope however understand it or ever came across this kind of problem can able to give me the solution.

  • 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-17T21:32:30+00:00Added an answer on May 17, 2026 at 9:32 pm

    HTML

    <a href="#" class="add my_encounter">Add</a>
    

    JS

    $('.my_encounter').bind('click', function(event) {
    
        if ((this).hasClass('add')){ //add_encounter
          //encounters ???
          $(this).removeClass('add').addClass("submitter")
    
        }
        else if ((this).hasClass('submitter')){  // save
          var encounter = $('#name').val(),
              key = $('#encounterKey').val();
    
          if (key == '') {
             key = null
          }
          if (encounter == ''){
            // cancel_encounter
            $(this)
               .removeClass("submitter")
               .addClass("add")
               .text("Add"); //?? where remove text "Add"
          }
    
        }
    
        event.preventDefault();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this code: $('.access a').toggle(function() { $('link').attr('href', 'styles/accessstyles.css'); $('body').css('font-size', '16px'); }, function() {
I have this href link with text either attivo or non attivo User can
I have used href link in the flexigrid rows. on Click it takes me
I have the html below: <span class=srch-URL> <a id=CSR_U_2 href=http://www.test.com/TestForm.aspx>http://www.test.com/TestForm.aspx</a> </span> I am trying
I have a table setup like below: <table> <tr> <td class=url> <a href=http://www.domainname.com/page1.html />
I have a JQuery Accordion as below; <div id=accordion> <h3 class=ui-accordion-header><a id=link1 href=#>First Header</a></h3>
I have a link that looks like a button from this html <p class=link-styleContact><a
I have below Jquery with me. $(.load-fragment).each(function() { var $objThis = $(this); var fname
I have a href link and I would like it to be clicked when
Suppose on my HTML page I have many href s to a link. Using

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.