js 点击文字弹出窗口问题

JavaScript06

js 点击文字弹出窗口问题,第1张

var text1, text2

function OpenDiv(_Dw,_Dh,_Desc) {

text1="好天气???"

text2="好麻烦啊??"

改成

var text1, text2

text1="好天气???"

text2="好麻烦啊??"

function OpenDiv(_Dw,_Dh,_Desc) {

因为你第一次执行时,text1和text2跟本没有给赋值。

当第一次点后才赋的值。以后再点当然显示正常了。

js实现点击输入用户名或密码的文本框在旁边弹出提示语 你可以使用formValidator.js,专门做表单验证的,效果如下:用法很简单,引用formValidator.js的核心类库,然后初始化$.formValidator.initConfig({formid: main ,debug:false,submitOnce : true})然后对要做校验的文本框编写校验代码$( #employeeNo ).formValidator({onshow : 输入范围为1到10个字符 ,在后面对应的显示提示语formValidator.js这个网上有很多实例和教程,很简单的

(function (document) {

var ttel = document.createElement('span')

ttel.style.position = 'absolute'

ttel.style.boder = '1px solid #e1dec9'

ttel.style.backgroundColor = '#eae9e3'

ttel.style.left = '0px'

ttel.style.top = '0px'

ttel.style.fontSize = '8pt'

ttel.style.padding = '2px 4px 2px 4px'

ttel.style.zIndex = 9999999

document.body.appendChild(ttel)

function showTooltip(e) {

console.log(e)

ttel.innerHTML = this.innerText || this.textContent || this.value

ttel.style.left = (e.pageX + 10) + 'px'

ttel.style.top = (e.pageY + 10) + 'px'

ttel.style.display = 'block'

return false

}

function hideTooltip(e) {

ttel.style.display = 'none'

ttel.innerHTML = ''

return false

}

function isTextNode(el) {

var children = el.children

if (el.childElementCount == 0)

return true

for (var i = 0 i < children.length i++) {

el = children[i]

var text = ((typeof el.innerText !== 'undefined' && el.innerText != '') ? el.innerText : el.textContent) || el.value

if (text)

return false

}

return true

}

function bindEvent(el) {

var children = el.children

if (children.length == 0 || isTextNode(el)) {

var text = ((typeof el.innerText !== 'undefined' && el.innerText != '') ? el.innerText : el.textContent) || el.value

if ((typeof text !== 'undefined' && text != '')) {

if (el.attachEvent) {

el.attachEvent('onmouseover', showTooltip)

el.attachEvent('onmouseout', hideTooltip)

} else if (el.addEventListener) {

el.addEventListener('mouseover', showTooltip)

el.addEventListener('mouseout', hideTooltip)

}

}

} else {

for (var i = 0 i < children.length i++) {

if (children[i])

bindEvent(children[i])

}

}

}

var el = document.body

bindEvent(el)

})(document)