简体   繁体   中英

How To Change the content/value of button with jQuery with it being in its hover state

i have a button and would like to change the content of it when its in its hover state. I looked through alot of the question that may already have my answer, and unfortunately came up blank, your help is greatly appreciated. This is what i have so far

Thanks Guys

$("#button").hover(function(){
$(this).html("click me");
}

You can use hover() handler like this

 $("#button").hover(function() { $(this).html("click me"); }, function() { $(this).html("click"); }) 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <button id=button>click</button> 

Update : If you are using input tag then use val() instead of html()

 $("#button").hover(function() { $(this).val("click me"); }, function() { $(this).val("click"); }) 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <input type=button id=button value=click> 

 $("#button1").hover(function() { $(this).val("click me"); }, function() { $(this).val("hi") }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input id="button1" type="button" value="hi"> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM