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);
    },
    });
    })
    })

  • 相关阅读:
    php文件 基本语法
    DBDA类 连接数据库 返回Json 返回字符串
    全选复选框做法
    弹窗js
    AJAX
    弹窗JS CSS
    JavaScript
    链接数据库 类
    PHP 分页 查询
    Foreach嵌套Foreach
  • 原文地址:https://www.cnblogs.com/daochong/p/10278566.html
Copyright © 2011-2022 走看看