我有一个验证脚本,我想要检查名字字段是否留空。 我最初只是更改了字段的背景颜色,但是现在我想使用jquery淡入高亮显示。 到目前为止这是代码。
var x = document.forms['getinfo']['fname'].value; var validated = true; if (x==null || x =="") { //document.getElementById('trfname').style.background="#FF9999"; document.getElementById('trfname').style.borderRadius = '7px'; $("trfname").effect("highlight", {}, 3000); validated = false; }正如你所看到的,我注释掉了有效的旧javascript代码,我正在尝试使用jquery高亮功能。 它没有用,我想知道是否有人有一些意见。 我已经检查过Jquery是否正确加载它确实如此,所以它不是那样的。 我还包括了jquery-ui库,但无济于事。
I have a validation script, and I'm tying to check if the first name field is left blank. I originally just changed the background color of the field and that worked, but now I want to use jquery to fade in a highlight. This is the code so far.
var x = document.forms['getinfo']['fname'].value; var validated = true; if (x==null || x =="") { //document.getElementById('trfname').style.background="#FF9999"; document.getElementById('trfname').style.borderRadius = '7px'; $("trfname").effect("highlight", {}, 3000); validated = false; }As you can see I commented out the old javascript code that worked and I'm trying to use the jquery highlight function. It's not working and I was wondering if anyone had some input. I've checked if Jquery loads properly and it does, so it's not that. I also included the jquery-ui library, to no avail.
最满意答案
您正在寻找名为trfname的元素,而不是id。 添加缺少的# 。
$("#trfname").effect("highlight", {}, 3000);You are looking for an element named trfname, not an id. Add the missing #.
$("#trfname").effect("highlight", {}, 3000);更多推荐
发布评论