< div>< / div>中的ID名称对? [英] ID names within a <div></div> pair?

查看:85
本文介绍了< div>< / div>中的ID名称对?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,


在Javascript中,是否可以获取所有ID名称,例如,

< div>< / divpair ?就像document.images数组一样,我的意思是。


我问的原因是,我有一个< td>< / tdtable
的日历在给定的< div>< / div>中,
元素都具有类类型,其中一个元素类型为

为今天。 (突出它)。一旦绘制了日历,Javascript

就结束了。而且由于Javascript没有已知(对我来说)存储

变量的方法,比如系统环境,重新使用时我将不得不求助于

取消我可以在日历之前使用日历中所有ID的类

突出显示另一天。


有意义吗? :)


谢谢,


- 马克

解决方案

2月27日下午4:03,标记 < a ... @ asarian-host.netwrote:


亲爱的朋友们,


在Javascript中,是否有可能获取所有ID名称,例如,

< div>< / divpair?就像document.images数组一样,我的意思是。


我问的原因是,我有一个< td>< / tdtable
的日历在给定的< div>< / div>中,
元素都具有类类型,其中一个元素类型为

为今天。 (突出它)。一旦绘制了日历,Javascript

就结束了。而且由于Javascript没有已知(对我来说)存储

变量的方法,比如系统环境,重新使用时我将不得不求助于

取消我可以在日历之前使用日历中所有ID的类来强调另一天。



如果您愿意,可以创建一个存储对单元格的引用的持久对象

。还有各种各样的例子:

" getElementsByClassName"档案中的功能。您还可以给多个类提供

元素,然后根据需要添加和删除它们。


一种技术是根据日期为表格单元格提供一个ID那些

代表(记得总是在数字前加上字母

确保有效ID),然后在更改日期时更改ID -

一切皆有可能。有数百个日历脚本已经出现

,Matt Kruse在这里有一个:


< URL: http://www.javascripttoolbox.com/lib/calendar/ >


虽然需要修改它来修改日期格式

更适合网络(它使用美国特有的mm / dd / yyyy

格式) - 我认为这不会太难。

-

Rob

" RobG" < rg *** @ iinet.net.auwrote in message

news:11 ********************** @ z35g2000cwz。 googlegr oups.com ...


非常感谢。这是一个非常有用的答案! :)


- Mark


在comp.lang.javascript消息中< 11 ********* *************@z35g2000cwz.go

oglegroups.com>,星期一,2007年2月26日22:50:44,RobG< rg *** @ iinet .net.au>

发布:


已经有数百个日历脚本了,Matt Kruse在这里有一个:

< URL: http:// www。 javascripttoolbox.com/lib/calendar/ >

虽然需要修改它以将日期格式修改为更适合网络的东西(它使用美国'特殊的mm / dd / yyyy
格式) - 我认为这不会太难。



它也是在星期日开始的一周,尽管全能者明天周一首选

。但是德语是指德语。日历只需要将

单词从德语翻译成本地首选项。当然,没有提到

国际标准。周我没有看到任何内容

数字。


而(this.getDay()%6 == 0)//比

while(this.getDay()== 0 || this.getDay()== 6)


IIRC,this.setHours(0,0,0,0) );在IE4工作。


在验证时,没有必要检查Leapness,直到确定它是2月29日为止的
。但是对于较短的代码,可以将
与28 + Leap(Y)的日期进行比较。


In< http://www.javascripttoolbox.com/ lib / date / examples.php> ;,添加

时间演示必须有问题。如果我加上7500000秒和0..7年

到2000-01-01 01:00:00,我不应该总是得到同一时间。

它的输入窗口太窄,但75e5适合。


添加年月天结果

7 2 23 2007年3月24日1:00:00上午(星期六)

7 2 24 2007年3月25日上午12:00:00(星期日)

7 2 25 2007年3月26日凌晨1:00:00(星期一)


其中一天有一个小时不同。


添加7 2 23 23 59 00 - 2007年3月25日12: 59:00 AM(星期日)

添加7 2 23 23 59 60 - 2007年3月25日12:00:00(星期日)


所以添加60秒还能让它提前一小时。如果使用ISO格式或用户的选择,页面将更好




N.B.北美人(大多数)将能够进行相应的测试但是具有不同日期和时间的
。记住ISO 16262:2002 15.9.1.8,最后

段落第120页。 (ECMA:第一段)。

BTW,ISO 8601:2004以PDF格式(普通和拉链)在网上发布。


-

(c)John Stockton,英国萨里。 ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.

Web< URL:http://www.merlyn.demon.co.uk/- w。常见问题主题,链接,首字母缩略词

PAS EXE等:< URL:http://www.merlyn.demon.co.uk/programs/-见00index.htm

日期 - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm等


Dear folks,

In Javascript, is it possible to get all id names within, say, a
<div></divpair? Like the array of "document.images", I mean.

The reason I ask, is that I have a calender whose <td></tdtable
elements, within a given <div></div>, all have a class type, one of which
is "today" (to highlight it). Once the calender is drawn, the Javascript
has ended. And since Javascript has no known (to me) method of storing
variables in say, the system environment, on re-use I''ll have to resort to
canceling the classes for all ids within the calender before I can
highlight a different day.

Make sense? :)

Thanks,

- Mark

解决方案

On Feb 27, 4:03 pm, "Mark" <a...@asarian-host.netwrote:

Dear folks,

In Javascript, is it possible to get all id names within, say, a
<div></divpair? Like the array of "document.images", I mean.

The reason I ask, is that I have a calender whose <td></tdtable
elements, within a given <div></div>, all have a class type, one of which
is "today" (to highlight it). Once the calender is drawn, the Javascript
has ended. And since Javascript has no known (to me) method of storing
variables in say, the system environment, on re-use I''ll have to resort to
canceling the classes for all ids within the calender before I can
highlight a different day.

You can make a persistent object that stores references to the cells
if you like. There are also various examples of
"getElementsByClassName" functions in the archives. You can also give
elements multiple classes, then add and remove them as required.

One technique is to give the table cells an ID based on the date that
they represent (remember to always prefix numbers with a letter to
ensure valid IDs), then you change the IDs as you change the dates -
anything is possible. There are hundreds of calendar scripts out
there already, Matt Kruse has one here:

<URL: http://www.javascripttoolbox.com/lib/calendar/ >

although it needs to be modified to fix the date format to something
more appropriate for the web (it uses the USA''s peculiar mm/dd/yyyy
format) - I don''t think it would be too difficult.
--
Rob


"RobG" <rg***@iinet.net.auwrote in message
news:11**********************@z35g2000cwz.googlegr oups.com...

Thank you very much. That was an extremely helpful answer! :)

- Mark


In comp.lang.javascript message <11**********************@z35g2000cwz.go
oglegroups.com>, Mon, 26 Feb 2007 22:50:44, RobG <rg***@iinet.net.au>
posted:

There are hundreds of calendar scripts out
there already, Matt Kruse has one here:

<URL: http://www.javascripttoolbox.com/lib/calendar/ >

although it needs to be modified to fix the date format to something
more appropriate for the web (it uses the USA''s peculiar mm/dd/yyyy
format) - I don''t think it would be too difficult.

It also starts the week with Sunday, even though the Almighty apparently
preferred Monday for that. But the "German" calendar just needs the
words to be translated from German to local preference. No mention of
the International Standard, of course. And I saw nothing on Week
Numbers.

while(this.getDay()%6==0) // is shorter than
while(this.getDay()==0 || this.getDay()==6)

IIRC, this.setHours(0, 0, 0, 0); worked in IE4.

In validating, there''s no need to check for Leapness until it has been
established that it is a Feb 29 date. But for shorter code one can
compare the date with 28+Leap(Y) .

In <http://www.javascripttoolbox.com/lib/date/examples.php>, the "Adding
Time" demo must have a problem. If I add 7500000 seconds and 0..7 years
to 2000-01-01 01:00:00, I should not always get the same time of day.
And its input windows are too narrow, though 75e5 will fit.

Adding Years Months Days Result
7 2 23 March 24, 2007 1:00:00 AM (Saturday)
7 2 24 March 25, 2007 12:00:00 AM (Sunday)
7 2 25 March 26, 2007 1:00:00 AM (Monday)

One hour different, on one of the days.

Adding 7 2 23 23 59 00 -March 25, 2007 12:59:00 AM (Sunday)
Adding 7 2 23 23 59 60 -March 25, 2007 12:00:00 AM (Sunday)

so adding 60 seconds more makes it an hour earlier. The page would be
better if that used ISO format, or user''s choice.

N.B. North Americans will (mostly) be able to do corresponding tests but
with a different date and time. Remember ISO 16262:2002 15.9.1.8, last
paragraph of p.120. (ECMA : first para).
BTW, ISO 8601:2004 is published on the Web in PDF (plain & zip).

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.


这篇关于&lt; div&gt;&lt; / div&gt;中的ID名称对?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆