我爱编程

jQuery选择器_Dom操作_样式_事件处理_动画

2017-09-02  本文已影响0人  Taaaaaaaurus

题目1: jQuery 能做什么?

上面的代码表示:为使用的.show-details样式的button元素添加一个click事件,事件就是:显示使用.details样式的DIV。

题目2: jQuery 对象和 DOM 原生对象有什么区别?如何转化?

题目3:jQuery中如何绑定事件?bind、unbind、delegate、live、on、off都有什么作用?推荐使用哪种?使用on绑定事件使用事件代理的写法?

绑定事件和解绑事件推荐使用on()off()

题目4:jQuery 如何展示/隐藏元素?

题目5: jQuery 动画如何使用?
.animate( properties [, duration ] [, easing ] [, complete ] )
用法:jquery对象.animate(执行动作(一般都是css样式),回调函数(可选));
例子:

<!DOCTYPE html>
<html>
<head>
    <script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
    <meta charset="utf-8">
    <title>JS Bin</title>
    <style>
        #ct {
            border: 1px solid black;
            width: 100px;
            height: 100px;
            background: red;
            position: relative;
        }
    </style>
</head>
<body>
    <div id="ct">animate</div>
    <button type="button">动画</button>
    <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
    <script>
        $('button').on('click', function a() {
            $('#ct').animate({
                left: '300px',
            }, 3000);
            $('#ct').animate({
                top: '300px',
                left: '0'
            }, 'slow');
            $('#ct').animate({
                left: '300'
            }, 'slow');
            $('#ct').animate({
                left: '0',
                top: '0'
            }, 'slow');
        });
    </script>
</body>
</html>

题目6:如何设置和获取元素内部 HTML 内容?如何设置和获取元素内部文本?

题目7:如何设置和获取表单用户输入或者选择的内容?如何设置和获取元素属性?

代码8
)
代码9
代码10
代码11

上一篇 下一篇

猜你喜欢

热点阅读