Find all elements whose id begins with a common string

前端 未结 5 726
臣服心动
臣服心动 2020-12-01 09:01

I have a XSL that created multiple elements with the id of \"createdOn\" plus a $unique-id

Example : createdOnid0xfff5db30

I want to find a

5条回答
  •  长情又很酷
    2020-12-01 09:45

    Try the following:

    var values = new Array(valueKey_1);
    var keys = new Array("nameKey_1");
    var form = document.forms[0];
    for (var i = 0; i < form.length; i++) {
        name = form.elements[i].name;
        var startName = name.toLowerCase().substring(0, 18);
        if (startName == 'startStringExample') {
        values.push(name.value);
        keys.push(name);
        }
    }
    

提交回复
热议问题