添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
性感的生菜  ·  USAJOBS - Search·  1 周前    · 
高大的春卷  ·  jsp ...·  2 月前    · 
暗恋学妹的铅笔  ·  WPF MVVM 循序渐进 ...·  3 月前    · 

Repository files navigation

jquery.if-else

When using chained function calls in jQuery, it happens that you only want some of the functions to be called under specific conditions. With this plugin, you can use if(), else(), elif() and fi() to accomplish this.

$(mySelector)
  .css("color", "blue")
  .if(someCondition)
    .css("background", "red")
  .else()
    .css("background", "orange")
  .fi()
  .css("font-size", "22px");

The plugin also supports nesting of if conditions:

$(mySelector)
  .css("color", "blue")
  .if(someCondition)
    .css("background", "red")
    .if(anotherCondition)
      .text("Yep")
    .else()
      .text("Nop")
    .fi()
  .else()
    .css("background", "orange")
  .fi()
  .css("font-size", "22px");

Enjoy!