zoukankan      html  css  js  c++  java
  • mui mui-control-item获得选中的标签

    function getActiveControl() {
    var segmentedControl = document.getElementById("top-scroll");
    var links = segmentedControl.getElementsByTagName('a');
    for (var i = 0; i < links.length; i++) {
    if (links[i].getAttribute('class').indexOf('mui-active') > 0) {
    var id = links[i].getAttribute('href');
    return id;
    }
    }
    }
    document.querySelectorAll(".mui-control-item").forEach(function(item){
    item.addEventListener('tap', function () {
    console.log(getActiveControl())
    })
    })

    改进后:

    <a class='mui-control-item' href="#item2mobile" val="16">女装</a>

    document.querySelectorAll(".mui-control-item").forEach(function(item){
    item.addEventListener('tap', function () {
    var cat_id = item.getAttribute('val')
    mui.ajax(__test_api_url+'/Tbk/optionalMaterialId', {
    data:{
    'token':__tbk_token,
    'page':1,
    'adzoneId':__adzone_id,
    'catId':cat_id,
    },
    dataType: 'json',
    type: 'post',
    async: false,
    headers: {'Content-Type': 'application/json'},
    success: function (jsondata) {
    console.log(jsondata);
    },
    });
    })
    })

  • 相关阅读:
    jenkins代码自动部署
    jenkins安装
    git图形管理工具
    gitlab自动备份恢复与卸载
    linux下获取外网IP
    网站安全webshell扫描
    jQuery动画效果实现
    form表单中的enctype属性什么意思?
    你那么努力又怎么样!
    话语
  • 原文地址:https://www.cnblogs.com/daochong/p/10278566.html
Copyright © 2011-2022 走看看