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 on Sun Sep 21, 2014 11:40 am

Help me with this please.

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

View user profile

2
Re: document.getElementByID on 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?

View user profile http://lolwesta.forummotions.com

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

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.

View user profile

4
Re: document.getElementByID on 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.

View user profile http://lolwesta.forummotions.com

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

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

View user profile

6
Re: document.getElementByID on 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.

View user profile http://lolwesta.forummotions.com

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

sugar


Members
Members
will this works ?

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

reference

View user profile

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

LOLWesta


LOLWesta King
Nope. That won't work.

View user profile http://lolwesta.forummotions.com

9
Re: document.getElementByID on 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.

View user profile

10
Re: document.getElementByID on 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

View user profile

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