HTML DOM getElementsByName() 方法

HTML DOM getElementsByName() 方法

定义和用法

getElementsByName() 方法可返回带有指定名称的对象的集合。

语法

document.getElementsByName(name)

该方法与 getElementById() 方法相似,但是它查询元素的 name 属性,而不是 id 属性。

另外,因为一个文档中的 name 属性可能不唯一(如 HTML 表单中的单选按钮通常具有相同的 name 属性),所有 getElementsByName() 方法返回的是元素的数组,而不是一个元素。

实例

<html>
<head>
<script type="text/javascript">
function getElements()
  {
  var x=document.getElementsByName("myInput"); alert(x.length); } </script> </head> <body> <input name="myInput" type="text" size="20" /><br /> <input name="myInput" type="text" size="20" /><br /> <input name="myInput" type="text" size="20" /><br /> <br /> <input type="button" onclick="getElements()" value="How many elements named 'myInput'?" /> </body> </html>
<html>
<head>
<script type="text/javascript">
function getElements()
  {
  var x=document.getElementsByName("myInput"); alert(x.length); } </script> </head> <body> <input name="myInput" type="text" size="20" /><br /> <input name="myInput" type="text" size="20" /><br /> <input name="myInput" type="text" size="20" /><br /> <br /> <input type="button" onclick="getElements()" value="How many elements named 'myInput'?" /> </body> </html>

“HTML DOM getElementsByName() 方法”的6,447个回复

  1. Thanks for the auspicious writeup. It if truth be told was once a entertainment account it.

    Glance complex to far added agreeable from you!

    By tthe way, how could we communicate?

    Check out my web page … naturaal teeth whitening powder teeth (Earnest)

  2. Please let me know if you’re looking forr a author for your weblog.
    You have some really good articles and I think I would be
    a good asset. If you ever want to take some of the load off, I’d love to write some
    material for yur blog in exchange for a link back
    to mine. Please blast me aan e-mail if interested.
    Cheers!

    Here is my page – home oof persojal empowerment (Hope)

  3. Hello there! This post could not be written any
    better! Reading through this article reminds me of
    my previous roommate! He always kept preaching about this.
    I most certainly will forward this post to him. Fairly certain he will have
    a very good read. Thank you for sharing!

  4. This is a really good tip particularly to those fresh to the blogosphere.
    Brief but very precise information… Thank you for sharing
    this one. A must read post!

  5. I loved as much as you will receive carried out right
    here. The sketch is attractive, your authored material
    stylish. nonetheless, you command get bought an shakiness over that you
    wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly very often inside case you shield this increase.

  6. My family always say that I am killing my time here at web,
    except I know I am getting familiarity every
    day by reading thes pleasant articles or reviews.

  7. Hmm is anyone else experiencing problems with the pictures on this
    blog loading? I’m trying to find out if its a problem on my end or if it’s the blog.
    Any responses would be greatly appreciated.

  8. Excellent goods from you, man. I’ve understand your stuff previous to and you’re just extremely wonderful.

    I really like what you have acquired here, certainly like what you
    are saying and the way in which you say it. You make it entertaining and you still care for to keep it sensible.
    I can’t wait to read much more from you. This is really a tremendous
    web site.

  9. This is really interesting, You are a very skilled blogger.
    I have joined your rss feed and look forward to seeking more of your excellent post.

    Also, I’ve shared your site in my social networks!

  10. Attractive section of content. I just stumbled upon your
    site and in accession capital to assert that I get actually enjoyed account your blog posts.
    Anyway I will be subscribing to your augment and even I achievement you access consistently
    rapidly.

  11. Your style is really unique compared to other people I have read stuff from.
    I appreciate you for posting when you have the opportunity, Guess I’ll just book mark this page.

  12. I’m now nnot certzin where you’re getting your info, but good topic.
    I nseds to spend a while learning more or figuring out more.
    Thank you for fantastic info I was searching for this information for
    my mission.
    Live bet betting match site
    bet match

  13. Hey! Someone in my Myspace group shared this site with us so I came to take a look.

    I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers!

    Terrific blog and outstanding design and style.

  14. Pingback: viagra prices
  15. Hi there! This blog post could not be written any better!
    Looking at this post reminds me of my previous roommate! He always kept talking about this.
    I will send this information to him. Pretty sure he will have a great read.
    Thank you for sharing!

  16. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.
    You obviously know what youre talking about, why throw away
    your intelligence on just posting videos to your site when you could be giving us something informative
    to read?

  17. I will right away grasp your rss as I can’t find your e-mail subscription link or e-newsletter service.
    Do you’ve any? Please permit me know so that I may
    subscribe. Thanks.

  18. Hi! I know this is somewhat off topic but I was wondering if you knew
    where I could find a captcha plugin for my comment form?
    I’m using the same blog platform as yours and I’m having difficulty finding one?
    Thanks a lot!

  19. Its like you read my mind! You seem to know so much about this, like you wrote the book in it or something.
    I think that you could do with a few pics to drive the message home a
    little bit, but instead of that, this is fantastic blog.
    A great read. I will definitely be back.

  20. Pingback: viagra alternative
  21. Greetings! I know this is kinda off topic but I was wondering if you knew where I could find a captcha plugin for my comment
    form? I’m using the same blog platform as yours and
    I’m having difficulty finding one? Thanks a lot!

  22. I want to voice my respect for your generosity in support of all those that should have help with the concept.
    Your special dedication to getting the message all-around appeared to be particularly interesting and has continuously helped others just like me to arrive
    at their endeavors. Your valuable tips and hints means a
    lot a person like me and a whole lot more to my office colleagues.
    With thanks; from everyone of us.

  23. Nice post. I learn something totally new and challenging on blogs
    I stumbleupon on a daily basis. It’s always useful to read through articles from other writers and practice a little something from their websites.

  24. Pretty portion of content. I just stumbled upon your blog
    and in accession capital to say that I get actually enjoyed account your blog posts.

    Anyway I will be subscribing to your augment and even I success you
    get entry to consistently quickly.

  25. Hey, you used to write magnificent, but the last several posts have been kinda boring?
    I miss your great writings. Past few posts are just a bit out of track!
    come on!

  26. Great blog here! Also your site loads up very fast!
    What web host are you using? Can I get your affiliate link to your host?
    I wish my site loaded up as fast as yours lol

  27. Good post. I learn something new and challenging on websites I stumbleupon on a daily basis.

    It will always be exciting to read content from other authors and use a little something from their websites.

  28. Pingback: viagra canada
  29. What’s up it’s me, I am also visiting this website on a regular basis,
    this web page is actually fastidious and the visitors are genuinely sharing nice thoughts.

  30. With havin so much written content do you ever
    run into any issues of plagorism or copyright violation? My website has a lot of
    exclusive content I’ve either written myself or outsourced
    but it looks like a lot of it is popping it up all over the internet without
    my permission. Do you know any ways to help stop content from being ripped off?
    I’d really appreciate it.

  31. Nice post. I learn something totally new and challenging
    on sites I stumbleupon on a daily basis. It will always
    be interesting to read through content from other writers and use a little something from other websites.

  32. Pingback: buy viagra cheap
  33. What i do not realize is in reality how you are no longer really a lot more well-appreciated than you might be now.

    You are so intelligent. You already know therefore considerably on the subject of this matter,
    made me in my opinion imagine it from so many numerous angles.

    Its like men and women are not fascinated until it is something to do
    with Woman gaga! Your own stuffs nice. All
    the time maintain it up!

  34. Greetings I am so thrilled I found your weblog, I really found you by error, while I was browsing on Yahoo for something else, Nonetheless I am
    here now and would just like to say kudos for
    a marvelous post and a all round entertaining blog (I also love the theme/design), I don’t have time to look over it all at
    the moment but I have bookmarked it and also added
    in your RSS feeds, so when I have time I will be back to read a
    lot more, Please do keep up the great work.

  35. With havin so much content do you ever run into any problems of plagorism or copyright violation? My blog has a lot of
    unique content I’ve either written myself or outsourced but
    it looks like a lot of it is popping it up all over the internet without my agreement.
    Do you know any techniques to help protect against content from being stolen? I’d truly appreciate it.

  36. Hey there I am so grateful I found your site, I really found you by accident, while I was browsing on Yahoo for something else, Anyhow I am here now and would just
    like to say many thanks for a tremendous post and a all round interesting blog (I also love the theme/design), I don’t have time to look over it all at the minute but
    I have book-marked it and also added your RSS feeds, so when I have time I will be back to
    read much more, Please do keep up the excellent job.

  37. I have to point out my respect for your kindness in support of men and
    women who really need help on the study. Your very own dedication to getting
    the solution all-around turned out to be especially good
    and have specifically empowered some individuals just like me to get to their endeavors.
    Your helpful tutorial indicates a lot to me
    and still more to my office workers. Thanks a ton; from each one of us.

  38. Hello, you used to write great, but the last few posts have
    been kinda boring? I miss your tremendous writings. Past few posts are just a little bit out of track!
    come on!

  39. Pingback: levitra vs viagra
  40. Pretty part of content. I simply stumbled upon your website and in accession capital to assert that
    I get in fact enjoyed account your weblog posts.
    Anyway I will be subscribing to your feeds and even I fulfillment you access persistently
    quickly.

  41. Hello, you used to write wonderful, but the last few posts have been kinda
    boring? I miss your super writings. Past several posts
    are just a little out of track! come on!

  42. Have you ever considered about adding a little bit more than just
    your articles? I mean, what you say is important and all.
    However imagine if you added some great graphics or video clips
    to give your posts more, “pop”! Your content is excellent but with images and videos,
    this site could definitely be onee of the best
    in its field. Terrific blog!
    световое оформление зданий на новый год
    webpage
    новогоднее оформление фасадов фото

  43. Pretty element of content. I just stumbled upon your website and in accession capital to say that I get actually loved account your blog posts.
    Any way I’ll be subscribing in your feeds and
    even I success you get admission to persistently quickly.

  44. Pingback: brand viagra
  45. Howdy! Someone in my Myspace group shared this website with us so I came to look it over. I’m definitely enjoying the information. I’m bookmarking and will be tweeting this to my followers! Terrific blog and great style and design.

  46. I’m extremely impressed along with your writing abilities and also with the layout on your weblog. Is this a paid theme or did you modify it your self? Anyway stay up the nice high quality writing, it’s rare to see a nice blog like this one these days..

  47. I think this is among the so much significant information for
    me. And i’m happy reading your article. However want to remark on some general things, The site taste is wonderful,
    the articles is in point of fact nice : D.
    Just right job, cheers

  48. Hi there! Someone in my Myspace group shared this website with us so I came to check it out. I’m definitely enjoying the information. I’m book-marking and will be tweeting this to my followers! Great blog and excellent design and style.

  49. I’m impressed, I must say. Rarely do I encounter a
    blog that’s equally educative and engaging,
    and let me tell you, you have hit the nail on the head.
    The issue is something that not enough people are speaking intelligently about.
    Now i’m very happy that I came across this during my search for something regarding this.

  50. Hi there juust wanted to give you a quick heads up. The words in your post seem too be running
    off the screen in Safari. I’m not sure if this is a formatting issue
    or something to do with internet browser compatibility but I figured I’d post to let you know.

    The layout look great though! Hoope you get the ssue fixed soon. Thanks

    my web site :: trade the price action forex trading system laurentiu damir (Melva)

  51. Hey just wanted to give you a quick heads up and let you know a few of the images aren’t loading correctly.

    I’m not sure why but I think its a linking issue.
    I’ve tried it in two different internet browsers and both
    show the same results.

  52. Attractive part of content. I simply stumbled upon your website
    and in accession capital to claim that I get in fact loved account your weblog posts.

    Anyway I’ll be subscribing to your augment or even I achievement you get right of entry to consistently fast.

  53. Attractive part of content. I just stumbled upon your website and in accession capital to claim that I get in fact enjoyed account your blog posts.
    Any way I’ll be subscribing to your feeds and even I
    fulfillment you get right of entry to consistently rapidly.

  54. Hi, i think that i noticed you visited my blog so i came to ?go
    back the desire?.I’m trying to to find things to enhance
    my web site!I guess its adequate to use some of your concepts!!