开发者

Is it possible to choose the effect for a switchClass jQuery UI function?

开发者 https://www.devze.com 2022-12-08 06:29 出处:网络
I would like to add a subtle and quick fadeOut and FadeIn effect to a button change through switchClass.

I would like to add a subtle and quick fadeOut and FadeIn effect to a button change through switchClass.

j开发者_如何学PythonQuery("a#btnPause").switchClass(pauseClass,playClass,200);

The effect used by default is a slideLeft.

If I would use standard jQuery, I would like to put an effect on addClass and removeClass, but is that possible?


Is something like

$("a#btnPause").fadeOut(200).switchClass(pauseClass,playClass,200).fadeIn(200);

what you're looking for?


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui-1.8.16.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#btnDemo').click(function () {
                $('a#btnPause').fadeOut(200).switchClass('pauseClass', 'playClass', 200).fadeIn(200);
            });
        });
    </script>
    <style type="text/css">
        .pauseClass
        {
            color: Red;
        }

        .playClass
        {
            color: Green;
        }
    </style>
</head>
<body>
    <a id="btnPause" class="pauseClass">Text</a>
    <input type="button" id="btnDemo" value="Demo" />
</body>
</html>
0

精彩评论

暂无评论...
验证码 换一张
取 消