easyui- nodeName

本文解决了一个在使用EasyUI框架中遇到的问题:通过JavaScript无法正确读取日期选择框的值,导致出现TypeError错误。问题根源在于选择器的不正确使用,正确的做法是使用ID选择器而非直接变量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Uncaught TypeError: Cannot read property ‘nodeName’ of undefined 问题

html:

日期:<input type="text" name="time1" id="time1" class="easyui-datetimebox" Style="width: 120px; margin-top: 25px" />
到<input type="text" name="time2"   id="time2" class="easyui-datetimebox" Style="width: 120px; margin-top: 25px" />
	<a id="btn" class="easyui-linkbutton" "UpladTime()" data-options="iconCls:'icon-search'">查找</a>`
	
	<table id="tt" class="easyui-datagrid" style="width: 100%; height: 250px"
	title="查找列表" iconCls="icon-filter" rownumbers="true">

js:

  var time1 = $(time1).datebox('getValue');
  var time2 = $(time2).datebox('getValue');
  $.get(url, function(data) {
		console.log("yes");
	}); 

出现此问题.说是: easyui不能获取获取未定义的属性“nodename”.
在这里插入图片描述
刚开始以为是 easyui 的datagrid 没有name=nodeName 的问题.加上了之后,仍然报错.
之后查了好多种解决方式
如: 有些元素没有id.只有name, 有些表单id重复., 等等.
与我的情况都不符合. 之后一步步追查,发现与datagird没关系.是获取方式问题.

正确获取方式:
var time1 = $("#time1").datebox('getValue');  

之前也是出国此问题,解决之后忘记了.这次记下来! (ง •̀_•́)ง

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值