Hi guys, I am working on my javascript to create the text in the html document. I want to know how I can write the text in html? I tried to use this: var test=myFunction(); function myFunction(test) { var keycode; if (window.event) keycode = window.event.keyCode; { document.write("hello! this is a test"); } } Code (markup): It did not write the text in the html. I tried to find the solution but i can't. Can you please help me? thanks in advance.
Best thing would be is to use jQuery. You can use selectors to insert the html into specific areas like below. <!DOCTYPE html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript"> $(function() { // define function function myFunction() { $('body').html('<h1>New HTML Code Inserted'); } // call function myFunction(); }); </script> </head> <body> </body> HTML: This should get you started in the lovely world of jQuery.
Can you tell me what is jQuery? Can they work with JavaScript and php at the same time? How I can find out if my web hosting have got them in the control panel?
jQuery is a fat bloated library used by inept retards to piss all over websites because they don't know how to use javascript properly or want to throw it at everything for goofy animations that have no business on a website, or is CSS' job. I pity the people too stupid to realize how badly they are {explitive omitted} over their own websites with it. Ah, the asshat world of jQuery. As to your question, I'm not sure I'm following what the devil you are even trying to do... It looks like something javascript shouldn't even be doing in the first place -- Are you trying to capture a keypress? why are you sending that function to a variable? Is there more code than that we're not seeing because to be frank, that's 100% gibberish. ... and even if you were doing it on keypress, once the page is loaded doing a document.write will erase the entire page, and I suspect that is NOT what you are trying to do. It almost sounds like what you want to do should be handled using the DOM -- but without a better explanation of what you are trying to accomplish I wouldn't even ATTEMPT to try and make code for that. Hell, passing the function to itself should it actually get called would create an endless loop... so that's even WORSE gibberish.
Well look, i am newbie on this and i don't know what is all about and your post is not making any sense at all so don't be a fucking retard. I don't expected to a retard like you being a dick over the Internet to showed it off his skills so grow up and show your fucking respect to the society who don't know much about what jQuery supposed to do. You are a twat. I am not going to answer your question as you a retard, so think TWICE before you say something to somebody else if you want them to not be rude to you or show respect.
Wow, the insulting part wasn't even directed at YOU, but at jQuery as a way of warning you AWAY from it -- just as I would warn you away from Dreamweaver or tell you if you really wanted to use Wordpress you should gut out half of what it tries to shove down your throat for markup... As to the rest, you don't even want to explain what you want to do? Just how are we supposed to help you do it then? Nope, straight to the kneejerk reaction rather than taking the time to understand the intent or explain what you are trying to do. Unless you're upset I called your code gibberish -- if you're just starting out this surprises you?!? Whiskey Tango Foxtrot?
Hi there! Working on the basis of the title, you're looking to output the the browser? Ensure the below is within the body section of the document as shown. <body> <script type="text/javascript"> document.write('Hello World'); </script> </body> HTML: This will output Hello World to your browser.
OP for testing , just use console.log("my test") and see the output in firebug (google it) / chrome dev tools. If you want to create text inside html, then instead of document.write , explore innerHTML. Something like : InnerHTML isn't recommended ( I don't know why) , but it should get you on the right track. post = document.getElementById("SomeId"); post.innerHTML = "yo"; Code (markup):
jQuery is a framework for JavaScript and the main advantage of using this is that it works across the board on all browsers. This won't effect anything that your site has in terms of PHP as JavaScript works on client end not server. Check out the site here: http://jquery.com/