我正在尝试获取不同的元素 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";
}
};
最佳答案
function tooltipshow(ID, tooltip) {
document.getElementById(ID).setAttribute('title', tooltip);
}
for (item in data) {
if (data.hasOwnProperty(item)) {
tooltipshow(item, data[item]);
}
}
关于c# - 根据不同的元素id设置工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15194140/