`
luckyjaky
  • 浏览: 112146 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

css与attr、trigger()与toggle()的区别

CSS 
阅读更多
       <select multiple="multiple" class="content" id="select2" style="width: 100px; font-size:12px; height: 160px;">
            <option value="8">选项8</option>
        </select>

    alert($("#select2").attr("class"));   运行结果为“content”.

    attr为属性,即该元素除style属性外的所有属性都可以用attr表示。

 

   ("#select2").css("font-size");   运行结果为“12px”.

   css为样式,即style里面的内容。

 

  •    toggle()方法用于模拟鼠标连续单击事件,用于切换效果。toggleclass()重复切换类名。
  •    triggle()方法用于模拟操作。例如用户必须通过单击按钮才能出发click事件,但是有时需要通过模拟用户操作, 来达到单击的效果,例如用户进入页面后,就触发click事件,而不需要用户去主动单击看,就可以用triggle()方法。例如页面一加载进来就触发单击操作就用$("#btn").triggle("click"),也可以简化为$("#btn").click().
分享到:
评论

相关推荐

    Jquery 1.3 简体中文手册

    trigger(type, [data]) triggerHandler(type, [data]) unbind([type], [data]) 事件委派 live(type, fn) die([type], [fn]) 事件切换 hover(over, out) toggle(fn, fn2, [fn3, fn4, ...]) 事件 blur( [fn] ) ...

    JQuery 1.3 中文参考手册

    trigger(type, [data]) triggerHandler(type, [data]) unbind([type], [data]) 事件委派 live(type, fn) die([type], [fn]) 事件切换 hover(over, out) toggle(fn, fn2, [fn3, fn4, ...]) 事件 blur( [fn] ) ...

    jQuery1.4 API

    jQuery.extend(object) 多库共存 jQuery.noConflict([ex]) 属性属性 attr(name) attr(properties) attr(key, value) attr(key, fn) removeAttr(name) CSS 类 addClass(class | fn) removeClass([class | fn]) ...

    jQuery 1.4.1 中文参考

    8.2.3 trigger(type, [data]) 123 8.2.4 triggerHandler(type, [data]) 124 8.2.5 unbind([type], [fn]) 125 8.3 事件委派 127 8.3.1 live(type, [data], fn) 127 8.3.2 die([type], [fn]) 130 8.4 事件切换 131 ...

    jQuery 1.5 API 中文版

    $.trigger( event [, data]) obj.triggerHandler( event [, data]) $.delegate( selector, type, [data], handler) $.undelegate( [selector, type, [handler]]) Live Events $.live( eventType [, data], fn() ) $....

    jQuery权威指南-源代码

    1.2.3 jQuery控制页面CSS /9 1.3 本章小结/11 第2章 jQuery 选择器/12 2.1 jQuery选择器概述/13 2.1.1 什么是选择器/13 2.1.2 选择器的优势/13 2.2 jQuery选择器详解/17 2.2.1 基本选择器/18 2.2.2 层次...

    jQuery详细教程

    提示:jQuery 使用的语法是 XPath 与 CSS 选择器语法的组合。在本教程接下来的章节,您将学习到更多有关选择器的语法。 文档就绪函数 您也许已经注意到在我们的实例中的所有 jQuery 函数位于一个 document ready ...

    jquery1.11.0手册

    attr(name|pro|key,val|fn) removeAttr(name) prop(n|p|k,v|f) removeProp(name) CSS 类 addClass(class|fn) removeClass([class|fn]) toggleClass(class|fn[,sw]) HTML代码/文本/值 html([val|fn]) text...

Global site tag (gtag.js) - Google Analytics