通过 jQuery 更改鼠标悬停时的动态按钮文本

曼朱纳斯

如何通过jQuery更改鼠标悬停时的动态按钮文本,

按钮

 <button type="button" id="sendRequest" ><span>Avialable Now</span></button>

查询

$(document).ready(function(){
    $('#sendRequest').hover(function() {
         $(this).find('span').text('Send Request');
    }, function() {
        $(this).find('span').text('Avialable Now');
 });
});

我想更改每个动态创建的按钮上的文本,上面我只能更改单个或第一个按钮上的文本。

马蒙

将您的选择器从$('#sendRequest')To更改$('button')这将提高event当前button.

$(document).ready(function(){
    $('button').hover(function() {
         $(this).find('span').text('Send Request');
    }, function() {
        $(this).find('span').text('Avialable Now');
 });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="button" id="sendRequest1" ><span>Avialable Now</span></button>
<button type="button" id="sendRequest2" ><span>Avialable Now</span></button>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章