获得一个字符串第一个字母。 [英] acess of a string first letter.
问题描述
我正在尝试创建一个在Opera 7.2,Explorer 6.0和
Mozilla 1.4中工作的网站。
我有代码:
var imgs = document.getElementsByTagName(" img");
alert(imgs [1] .id);
imgs [1]的id是a10。用Opera,Explorer和
Mozilla打开一个窗口,文本为a10。我写的时候:
var imgs = document.getElementsByTagName(" img");
alert(imgs [1] .id [0]);
在Mozilla中打开一个窗口,其中包含文本a。但在另外两个
的文本中,未定义。
是否有人知道是否有办法访问
字符串(在我的情况下是包含id名称的字符串)和Explorer,
Mozilla和Opera ??
感谢您将来的反馈。
-
Sergio del Amo。
Hi,
I am trying to create a web site to work in Opera 7.2, Explorer 6.0 and
Mozilla 1.4.
I have the code:
var imgs= document.getElementsByTagName("img");
alert(imgs[1].id);
The id of imgs[1] is a10. A window is open with Opera, Explorer and
Mozilla with the text "a10". When i write:
var imgs= document.getElementsByTagName("img");
alert(imgs[1].id[0]);
A window is open in Mozilla with the text "a". But in the other two with
the text "undefined".
Does anybody knows if there is a way to acces the first letter of a
string(in my case the string which contains the id name) with Explorer,
Mozilla and Opera??.
Thanks for your future feedback.
--
Sergio del Amo.
推荐答案
Sergio del Amo< se *** @ sbox.tugraz.at>写道:
Sergio del Amo <se***@sbox.tugraz.at> writes:
有没有人知道是否有办法获取
字符串的第一个字母
Does anybody knows if there is a way to acces the first letter of a
string
string.charAt(0)
或
string.substring(0,1)
或
string。 substr(0,1)
/ L
-
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML死亡颜色:< URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
''没有判断的信仰只会降低精神神圣。''
string.charAt(0)
or
string.substring(0,1)
or
string.substr(0,1)
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
''Faith without judgement merely degrades the spirit divine.''
JRS:文章< fz ******** **@hotpop.com> ;,见于
news:comp.lang.javascript,Lasse Reichstein Nielsen< lr*@hotpop.com>
发布于周六, 2003年11月1日19:33:11: -
JRS: In article <fz**********@hotpop.com>, seen in
news:comp.lang.javascript, Lasse Reichstein Nielsen <lr*@hotpop.com>
posted at Sat, 1 Nov 2003 19:33:11 :-
Sergio del Amo< se *** @ sbox.tugraz.at>写道:
Sergio del Amo <se***@sbox.tugraz.at> writes:
有没有人知道是否有办法获取
字符串的第一个字母
Does anybody knows if there is a way to acces the first letter of a
string
string.charAt( 0)
或
string.substring(0,1)
或
string.substr(0,1)
string.charAt(0)
or
string.substring(0,1)
or
string.substr(0,1)
和引用的问题:那些访问第一个字符,
假设有一个。
S ='''123go''
OK = /([az])/i.test(S)
RESULT = RegExp。
And for the question as quoted : those access the first character,
assuming that there is one.
S = ''123go''
OK = /([a-z])/i.test(S)
RESULT = RegExp.
1
给了我''g''。外面的字母需要更大的搜索字词
AZ。
JS的结果是什么?!?
>
-
?约翰斯托克顿,英国萨里。 ?@merlyn.demon.co.uk Turnpike v4.00 IE 4?
< URL:http://jibbering.com/faq/> Jim Ley的新闻常见问题解答:comp.lang.javascript
< URL:http://www.merlyn.demon.co.uk/js-index.htm> JS数学,日期,来源。
< URL:http://www.merlyn.demon.co.uk/> TP / BP / Delphi / JS /& c。,FAQ主题,链接。
1
gives me ''g''. A larger search term will be needed for letters outside
A-Z.
What''s Result for in JS?!?
--
? John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ?
<URL:http://jibbering.com/faq/> Jim Ley''s FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
这篇关于获得一个字符串第一个字母。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!