kstsca

如何取到触发焦点外部的元素数据。。路过看看,谢谢

  •  
  •   kstsca · Jun 21, 2014 · 4399 views
    This topic created in 4530 days ago, the information mentioned may be changed or developed.




    譬如如何取到“文章”这个数据,注意是点击span text后。
    8 replies  •  2014-06-22 19:37:59 +08:00
    switch
    switch
    Jun 21, 2014
    1
    先匹配到 ul.submenu 再查找到 .submenu-header:
    $this.closest("ul.submenu").children("li.submenu-header").text();
    kstsca
    kstsca
    OP
    Jun 21, 2014
    2
    @switch 但你无法定位哪一个。。Tables呢,这个有多个这个元素。。需要用到this
    paloalto
    paloalto
    Jun 21, 2014
    3
    $ul.on('click', 'span.text', function (e) {

    })
    paloalto
    paloalto
    Jun 21, 2014
    4
    @kstsca 1楼 给出的 $this.clesest('ul.submenu') 就是离 this 最近的那个 ul . 可以定位到的。

    而且可以直接匹配 id 啊,ul#form 是唯一的嘛。

    可以不用 this 的:
    $ul.on('click', 'span.text', function (e) {
    var text = $('ul#form .submenu-header').text();
    $('.page-header-section .semibold').text(text);
    })
    kstsca
    kstsca
    OP
    Jun 21, 2014
    5
    @paloalto 那#tables呢
    paloalto
    paloalto
    Jun 21, 2014
    6
    @kstsca 哦 还想用在 #tables 上啊 那就用1楼同学的写法吧。:P
    kstsca
    kstsca
    OP
    Jun 21, 2014
    7
    @paloalto 也不行。。必须用到this,但又不好获取到外面节点数据。
    liyandong
    liyandong
    Jun 22, 2014
    8
    找父亲的文章儿子
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2493 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 05:00 · PVG 13:00 · LAX 21:00 · JFK 00:00
    ♥ Do have faith in what you're doing.