根据不同的元素id设置工具提示

时间:2013-03-04 03:33:15

标签: c# javascript jquery asp.net

我正在尝试获取不同的元素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";


    }
};

1 个答案:

答案 0 :(得分:3)

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

for (item in data) {
    if (data.hasOwnProperty(item)) {
        tooltipshow(item, data[item]);
    }
}