0

我正在尝试获得不同的 elemenet id 并为每个人设置工具提示,但我无法做到

<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
<script type="text/javascript">
var data = {
    name: "enter your name",
    family: "enter your family",
    testfamily: "enter your family",
    uc1_txtname: "enter your name for Control 1 (User Control1)",
    uc2_txtname: "enter your name for Control 2 (User Control2)"
}
function tooltipshow() {

//trying to get different element id and set tooltip, the below code is just a sample
document.getElementbyID(dynamicID).Title = "DynamicTooltip based on element ID";


    }
};
4

1 回答 1

3
function tooltipshow(ID, tooltip) {
    document.getElementById(ID).setAttribute('title', tooltip);
}

for (item in data) {
    if (data.hasOwnProperty(item)) {
        tooltipshow(item, data[item]);
    }
}
于 2013-03-04T03:36:23.140 回答