English 中文(简体)
如果条件成熟, j脏行为
原标题:Weird behavior of jquery s if condition

I have a jquery datepicker plugin, here is the code: http://dpaste.com/639849/

真正的问题在于,如果条件永远得不到执行,那么这种高温功能就会发生。 条件是:

if ($( #id_checkin ).datepicker( getDate ) == date) {
  return [false,   ];
 }  

虽然我曾经尝试利用奥塞罗语制作日期变数和(pid_checkin)美元数值。 一方面,这两种价值观完全相同。 这里是两种数值的产出:

Fri Oct 28 2011 00:00:00 GMT+0530
Fri Oct 28 2011 00:00:00 GMT+0530

My problem is, if they match in value, why does not if statement believe so ? :( Please guide. Thanks

问题回答

它们是否属于同一类别,或只是指向相同的代表? Try change that to if ((#id_checkin ).datepicker (accessDate ).toString() =date.toString() and see whatyous.

edit: as to why... It could be because one of those values is some weird date object. JavaScript will try to coerce the types, but it will likely only work on types it knows about. My second guess is that one (or both) of those dates have a non-zero millisecond portion. Since milliseconds are not included in the output produced by called toString(), it is possible they match on their string representation but not on actual value. Try to output value property (assuming both sides are valid Date object) and see whats going on there.





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签