спасибо и на том. Вопрос решил. Может кому нужно будет
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
function prepareInputsForHints() {
var inputs = document.getElementsByTagName("input");
for (var i=0; i<inputs.length; i++){
inputs[i].onfocus = function () {
this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
}
inputs[i].onblur = function () {
this.parentNode.getElementsByTagName("span")[0].style.display = "none";
}
}
var selects = document.getElementsByTagName("select");
for (var k=0; k<selects.length; k++){
selects[k].onfocus = function () {
this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
}
selects[k].onblur = function () {
this.parentNode.getElementsByTagName("span")[0].style.display = "none";
}
}
var textareas = document.getElementsByTagName("textarea");
for (var m=0; m<textareas.length; m++){
textareas[m].onfocus = function () {
this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
}
textareas[m].onblur = function () {
this.parentNode.getElementsByTagName("span")[0].style.display = "none";
}
}
}
addLoadEvent(prepareInputsForHints);
html, после формы добавляем span с текстом
<span class="hint">какойто текст</span>
сss
Код:
|
.hint {
display: none;
position: absolute;
left: 350px;
top:5px;
width: 250px;
height:20px;
text-align:center;
box-shadow: 0 0 3px rgba(0,0,0,0.5);
margin-top:-5px;
border: 1px solid #ffffff;
padding: 3px 4px;
background: #f6f5f5 url(pointer.gif) no-repeat -10px 5px;
border-radius: 5px; |