jquery已加载,但未执行正确的UI功能(jquery loaded, but not executing proper UI function)

编程入门 行业动态 更新时间:2024-10-26 19:42:12
jquery已加载,但未执行正确的UI功能(jquery loaded, but not executing proper UI function)

我有一个验证脚本,我想要检查名字字段是否留空。 我最初只是更改了字段的背景颜色,但是现在我想使用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);

更多推荐

本文发布于:2023-07-16 07:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1125532.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:但未   加载   正确   功能   jquery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!