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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:31:38+00:00 2026-06-03T07:31:38+00:00

I have a button like below. I have a list of buttons. When user

  • 0

I have a button like below.
I have a list of buttons.
When user clicks it, I run a javascript function and it makes an ajax request, if request response is success, then I change status attribute of button tag. I change it from 1 to 2.

When the attribute status=1, I want user to see some text when hovering on button.

When the attribute status=2, I don’t want him to see anything on button hover.

I tried like below but after status=2, still button text changes on hover.
How can i fix this?

<button onclick="dosomething()" id="someid" status="1">name</button>

<script>
function dosomething(){
    $.ajax({
        type:"GET",
        url:"somefile.php",
        success : function(data) {
            if (data == '200') {
                $('#someid').attr('status', '2');
            }
        },
        error : function() {
            alert('error');
        },
    })
}

$(document).ready(function() {
    updateHoverStates()
});

$(document).change(function () {
    updateHoverStates()
});

function updateHoverStates() {
    $('button[status=1]').hover(
        function () {
            $(this).text('You are hovering');
        },
        function () {
            $(this).text('You are not hovering');
        }
    );
}
</script>
  • 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-03T07:31:39+00:00Added an answer on June 3, 2026 at 7:31 am

    This may work, that way the event is checking the staus attr each time it is called, instead of just once at bind time.

    function updateHoverStates() {
        $('button[status]').hover(
            function () {
                if($(this).attr('status') == '1')
                    $(this).text('You are hovering');
            },
            function () {
                if($(this).attr('status') == '1')
                    $(this).text('You are not hovering');
            }
        );
    }
    

    As a side note, I believe data-status would be a better supported way of having custom attributes, this also would allow the use of .data('status') instead of .attr('status').

    Alternatively you may be able to use CSS to simulate that

    button[status="1"]:hover {
        //possible attributes here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Most of my development life, I have done a JavaScript generated button like so:
I have a plus and minus button below a list in my cocoa application.
So I have a list with lots of items like below: <ul id=usersList> <li><FORM><INPUT
I have a Listview and a button like this Below is the code I
My application is looking like the below image I have 3 buttons in my
I have a button like this: <Button android:id=@+id/logout_button android:layout_width=fill_parent android:layout_height=wrap_content android:text=Log out /> and
I have one image submit button like this <input id=enter name=enter type=image value=Login src=images/btn_login.jpg/>
I need a button-like control that can have a Checked property, so that when
In Interface Builder components I have Gradient Button I would like to create this
I am doing this in order to have Facebook like button in my page:

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.