Jump to content

L8V2L thoughts on JavaScript...


L8V2L

Recommended Posts

Which API?

All, and if not, just the ones that have not been implanted in the browser. I mean what that be better, instead of waiting for those browser.And if jquery is just javascript... what is jquery?
Link to comment
Share on other sites

APIs give Javascript access to data that it can't get on its own.

 

jQuery is a program created using Javascript that makes some tasks easier.

Link to comment
Share on other sites

APIs give Javascript access to data that it can't get on its own. jQuery is a program created using Javascript that makes some tasks easier.

So all functionality of jQuery have a core of JavaScript? How do I access that? I more bent on using only JavaScript style.
Link to comment
Share on other sites

What feature do you want in Javascript? I'm quite sure it's not missing anything that you could possibly need.

 

Yes, everything jQuery does can be done in Javascript, but you have to be very good at Javascript to do it.

Link to comment
Share on other sites

I can't believe I read this entire thread. L8V2L, you are being pretty rude and demanding. I don't know why you feel so entitled or why everyone is so willing to help you. Just start building some things and if you have trouble, look in one of your manuals for a solution or just google it. This has already been said in this thread. I feel like you're just stringing everyone along here.

 

With that said, I'm going to stay away from this thread to prevent encouraging your behavior.

Link to comment
Share on other sites

What feature do you want in Javascript? I'm quite sure it's not missing anything that you could possibly need. Yes, everything jQuery does can be done in Javascript, but you have to be very good at Javascript to do it.

Ingolme... Is this true what he said??? I mean... I'm just posting up my question... I may have post up multiple question, but I don't mean to be rude... I don't know how to ask what I want to ask.. um is it true what he say... I mean does it look that what, do it look that way to you? I wanted to add something to canvas, a shape I feel like it could go great... actually it should have been in there already... it kinda is but not... not the way I feel it should.

I can't believe I read this entire thread. L8V2L, you are being pretty rude and demanding. I don't know why you feel so entitled or why everyone is so willing to help you. Just start building some things and if you have trouble, look in one of your manuals for a solution or just google it. This has already been said in this thread. I feel like you're just stringing everyone along here. With that said, I'm going to stay away from this thread to prevent encouraging your behavior.

Link to comment
Share on other sites

So all functionality of jQuery have a core of JavaScript? How do I access that? I more bent on using only JavaScript style.

just look at the source, yeesh

http://jquery.com/

Link to comment
Share on other sites

just look at the source, yeeshhttp://jquery.com/

That's to much for my novice mind to grasp yet... I been look at the source from when you first post this, I don't know what happen to me from replying back to you.
Link to comment
Share on other sites

WHY WON'T IT WORK! I hate to come here and ask this, I was going over the css3 new modules for background-Color, but with in JavaScript syntax backgroundColor, and came to try to make a toggle with it. but it want work for some reason, and it should! I feel lower than a novice to have to come here to ask this simplicity question.

<!DOCTYPE html><html><head><style>#myDIV{width:300px;height:300px;background-color:coral;color:white;}</style></head><body><p>Click the "Try it" button to set the background-color property of the DIV element to "lightblue":</p><button onclick="myFunction()">Try it</button><div id="myDIV"><h1>Hello</h1></div><script>var myD = document.getElementById("myDIV");function myFunction(){/*if(myD.style.backgroundColor == "coral"){myD.style.backgroundColor = "lightblue";}*/if(myD.style.backgroundColor == "lightblue"){ myD.style.backgroundColor = "pink";}else{myD.style.backgroundColor = "blue";}}</script></body></html>
Edited by L8V2L
Link to comment
Share on other sites

The reason your code doesn't work is that the background color is never being set to "lightblue"

That is the editing look, if you notice, I comment out the correct way when I went on a tempter on fingering out why it won't work...So my question still stand: WHY WON'T IT WORK! Edited by L8V2L
Link to comment
Share on other sites

I already told you why it doesn't work.

 

You have an if condition that is supposed to turn the box pink if the box's color is lightblue. The box's color is never lightblue so it never turns pink.

 

If you uncomment the other code you have another problem: The style attribute never was given the value "coral" and even if it did, once it has been set to another value you are not setting it back to "coral" anymore so that condition won't evaluate to true anymore.

Link to comment
Share on other sites

The problem is that in many cases Javascript cannot read the values set by css.

<!DOCTYPE html><html><head><meta charset="utf-8"><title>tab</title><style>#myDIV{ width:300px; height:300px; background-color:coral; color:white;}</style></head><body><p>Click the "Try it" button to set the background-color property of the DIV element to "lightblue":</p><button onclick="myFunction()">Try it</button><div id="myDIV"><h1>Hello</h1></div><div id="out1"></div><script>function myFunction(){var myD = document.getElementById("myDIV");document.getElementById("out1").innerHTML = 'color was:['+ myD.style.backgroundColor +']';if(myD.style.backgroundColor == "coral"){  myD.style.backgroundColor = "lightblue";}else if(myD.style.backgroundColor == "lightblue"){   myD.style.backgroundColor = "pink";}else if(myD.style.backgroundColor == "pink"){   myD.style.backgroundColor = "yellow";}else{  myD.style.backgroundColor = "coral";}}//end of function</script></body></html>
  • Like 1
Link to comment
Share on other sites

its because myD.style.backgroundColor == "", not "coral". Console.dir is your friend Javascript doesn't automatically populate the current computed CSS for any element, unless it made the change in the 1st place. You'd have to use window.getComputedStyle(myD) for it to load the current backgroundColor from that internal CSS. Even then it wouldn't always say "coral". Depending on the Browser it may decide to convert it to an rgb function like "rgb(255, 127, 80)".

 

Often its much less of a headache to simply make an extra CSS class and use javascript to change the classes an element has, rather than manually changing every single style in each element. its also much more cross-browser friendly.

  • Like 1
Link to comment
Share on other sites

IT WAS A FEAKING MISTYPE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! STUPID NOVICE ME!!!

Edited by L8V2L
Link to comment
Share on other sites

its because myD.style.backgroundColor == "", not "coral". Console.dir is your friend Javascript doesn't automatically populate the current computed CSS for any element, unless it made the change in the 1st place. You'd have to use window.getComputedStyle(myD) for it to load the current backgroundColor from that internal CSS. Even then it wouldn't always say "coral". Depending on the Browser it may decide to convert it to an rgb function like "rgb(255, 127, 80)". Often its much less of a headache to simply make an extra CSS class and use javascript to change the classes an element has, rather than manually changing every single style in each element. its also much more cross-browser friendly.

What do you mean?
Link to comment
Share on other sites

<!DOCTYPE html><html><body><h1>My First JavaScript</h1><p>JavaScript can change the content of an HTML element:</p><button type="button" onclick="myFunction()">Click Me!</button><p class="demo1">This is a demonstration.</p><script>//WHY WANT THIS WORK?!function myFunction() {     document.getElementsByClassName("demo1").innerHTML = "Hello JavaScript!";}</script></body></html>
Edited by L8V2L
Link to comment
Share on other sites

getElementsByClassNameThat does not return a single element, it returns a collection of 0 or more elements.

I was wondering about you! You been gone! Hope everything is alright with, and for you.... So, I would have to use
for(var i = 0; i < demo1.length; i++){demo[i].innerHTML="Hello World!";}
. Is this correct? Or would I have to do more, assuming that their only one element, and with a class name that no other elements have even if there was other elements... Could I also do it like this?
demo[0].innerHTML=("Hello World!");
. Is this, or and both of these correct?IT WORK!!!! THANK YOU JUSTSOMEGUY!!!!Would the first one work!?THE FIRST ONE WORK TOO!!! THANK YOU JUSTSOMEGUY!!!!! Edited by L8V2L
Link to comment
Share on other sites

Well, try them out and see.

<!DOCTYPE html><html><body><h1>My First JavaScript</h1><p>JavaScript can change the content of an HTML element:</p><button type="button" onclick="myFunction()">Click Me!</button><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><script>//WHY WANT THIS WORK?!function myFunction() {var demo1 = document.getElementsByClassName("demo1")for(var i = 2; i < demo1.length - 18; i++){demo1[i].innerHTML="Hello World!";}//demo1[0, 1, 2].innerHTML = "Hello JavaScript!";/*This will not work, it'll only change the third element in the array. Is there another way I can do this with out using array method?*/}</script></body></html>
Edited by L8V2L
Link to comment
Share on other sites

Guys, look; JavaScript:

<!DOCTYPE html><html><body><h1 class = "JS"></h1><p id="demo"></p><script>var person = {    firstName : "John",    lastName  : "Doe",    age       : 50,    eyeColor  : "blue"};var person1 = {    fN:"Hello",    lN:"JavaScript",    lU:"❤"};person1.prototype = person;document.getElementById("demo").innerHTML =person1.prototype.firstName + " is " + person1.prototype.age + " years old.";var JS = document.getElementsByClassName("JS");JS[0].innerHTML=person1.fN + " " + person1.lN + " " + person1.lU; </script></body></html>
THE POWER!!!!!! Edited by L8V2L
Link to comment
Share on other sites

for(var i = 2; i < demo1.length - 18; i++){demo1.innerHTML="Hello World!";}

You're building a test case, and you decide to lay down twenty-something elements and then loop from 2 to length minus 18? How about a sane test? How about looping through all of them and seeing if that works? You can also target a specific element as long as it is within the length.
Link to comment
Share on other sites

You're building a test case, and you decide to lay down twenty-something elements and then loop from 2 to length minus 18? How about a sane test? How about looping through all of them and seeing if that works? You can also target a specific element as long as it is within the length.

I did loop through all of them. The reason why it's like that is cause I was trying to figure out, how I can select a group of them in the middle.How do you select a group of them from one integer point to another. for example: 4-6.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...