LOLWesta, a social media forum


You are not connected. Please login or register

View previous topic View next topic Go down Message [Page 1 of 1]

1
document.getElementByID Empty document.getElementByID Sun Sep 21, 2014 11:40 am

Test Account


Members
Members
Help me with this please.

Code:
window.addEventListener('test', function() {
var foo = document.getElementByID('oops');
//do something here
}

2
document.getElementByID Empty Re: document.getElementByID Tue Sep 23, 2014 7:37 am

LOLWesta


LOLWesta King
Can you tell me what's the problem? And you do anything you want with that code. And what're you're working at the code?

https://lolwesta.forumotion.com

3
document.getElementByID Empty Re: document.getElementByID Tue Sep 23, 2014 8:22 am

Test Account


Members
Members
I'm not sure about what's it working with, yes I'll start to create that code since I've notice addEventListener and getElementByID things. So I still not sure about what's it currently working. I'll work with it in a few minutes, just sit down and wait.

4
document.getElementByID Empty Re: document.getElementByID Tue Sep 23, 2014 10:53 am

LOLWesta


LOLWesta King
Why won't you read the use of window.addEventListener and document.getElementByID at MDN. Or if you want the TL;DR version, go read it in W3Schools since it have example and such; and it's more simplest way.

So I'll explain something about document.getElementByID

It selects the current element of some ID. Some example, you want to select button with ID 'send'. So you do something like :

Code:
document.getElementByID('send').onclick(function () {
//run code.. in this example, we call some alert
alert('Hei-ho!');
}

or if you want to show some prompt before submitting :

Code:
document.getElementByID('sendbutton').onclick(function() {
//we prevent the form for being submitted
e.preventDefault();
//then do some action, prompt or whatever
prompt('Are you sure you want to submit this form?'); //or whatever

Seems that way.

https://lolwesta.forumotion.com

5
document.getElementByID Empty Re: document.getElementByID Wed Sep 24, 2014 1:04 pm

Test Account


Members
Members
Perfect.
Okay now I'm sure about how to use it. Let's see here :

Code:
var lol = document.getElementByID('lol');
lol.style.visibility = "hidden";
lol.style.display = "none";

Back to my progress. Will this work?

Code:
window.addEventListener('test', function() {
var foo = document.getElementByID('oops');
my_setcookie('lol')
}

Now I stopped writing at that point. :3

6
document.getElementByID Empty Re: document.getElementByID Thu Sep 25, 2014 7:55 am

LOLWesta


LOLWesta King
Anything you want. LOL Razz If you want to set a cookie, or a refresh function then yes.

https://lolwesta.forumotion.com

7
document.getElementByID Empty Re: document.getElementByID Tue Dec 23, 2014 5:54 am

sugar


Members
Members
will this works ?

Code:
var a = document.getElementById('subject');
a.autocomplete('off');

reference

8
document.getElementByID Empty Re: document.getElementByID Tue Dec 23, 2014 6:35 am

LOLWesta


LOLWesta King
Nope. That won't work.

https://lolwesta.forumotion.com

9
document.getElementByID Empty Re: document.getElementByID Sat Jan 17, 2015 10:36 am

Tsu


Members
Members
document.getElementById; will returns an object or neither null. It selects some ID before returning the object or returns null. Example here :

Code:
var url = document.getElementById('logoutlink');
if(url===null) {
// do stuff you need here
}else{
// do another stuff
}

Or if you want to returns an HTML object you can just use document.getElementById('logoutlink').innerHTML; instead.

10
document.getElementByID Empty Re: document.getElementByID Sat Jan 17, 2015 11:40 am

Left


Members
Members
Yes, it's true. You can convert the Object type into HTMLCollection with using .innerHTML Wink

So it's just like

Code:

<script>
foo = document.getElementById('id').innerHTML;
document.write(foo);
</script>
<div id="id">Sometimes I'm just wondering..</div>

So, it will write '
Sometimes I'm just wondering..
' unless of returns null / an object. Smile

Sponsored content


View previous topic View next topic Back to top Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum