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>
$(document).ready(...). This code is a real mess.statusattribute to keep your html valid...