最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Javascript get id - Stack Overflow

programmeradmin1浏览0评论
function check(id){
    var _id = document.getElementById(id);
    url = "test.php?check=1&id=" + _id;
}

i want the id in the url it's working but without the id that is in the check('123');

It's for an innerHTML to load something

hope you can help me with getting the id

Greetings

function check(id){
    var _id = document.getElementById(id);
    url = "test.php?check=1&id=" + _id;
}

i want the id in the url it's working but without the id that is in the check('123');

It's for an innerHTML to load something

hope you can help me with getting the id

Greetings

Share Improve this question edited May 13, 2009 at 9:35 ybo 17.2k2 gold badges30 silver badges31 bronze badges asked May 13, 2009 at 9:28 djairodjairo 2,7434 gold badges20 silver badges13 bronze badges 1
  • Can you post more of your code so we can understand whatyou are trying to achieve – Russ Cam Commented May 13, 2009 at 9:39
Add a ment  | 

2 Answers 2

Reset to default 4

The document.getElementId() function returns an object value based on the identifier string (ID) that you supply; therefore if you have an element on your page with the id of foo then you call

document.getElementById("foo");

to return the object for that element, so that you can manipulate it (changing styles, or attributes etc).

If you want to insert the id into the URL of the test.php page, why not simply pass the identifier string of the element that you pass in with the function?:

function check(id){
    url = "test.php?check=1&id=" + id;
}

Then calling

check("123");

will set the url variable to test.php?check=1&id=123

var _id = document.getElementById(id).id;

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论