Do I use JQuery or Javascript to make a prompt game?


#1

What code should I be using

also is there any way to combine JQuery and Javascript?


Do I use JQuery


  1. $(document).ready();

  2. or do I use Javascript

  3. console.log();

#2

jQuery is JavaScript.

prompt() is 'vanilla' JavaScript, not jQuery, but you can still use it in a jQuery script.

All jQuery is JavaScript, not all JavaScript is jQuery.


#3

okay. is there a way to use something like that prompt command in JQuery?


#4

also I was asking so I know what to finish for webpage design.


#5

Yes? Use that exact code: prompt() - it's all the same language.


#6

oh okay then I'll finish JQuery to learn how to implement that to the webpage


#7

Does the console.log command, When put in JQuery, log the output to the webpage?


#8

Look at the code. console .log(). Itlog()s to theconsole, nothing else.

If you want to debug, use alert() or if you want to add text to the page, well, there are loads of ways, so it may be worth a search.


#9

If you are writing a page in jQuery then forget the console and use form controls to get user input. Any messaging to the user should be in the web facing HTML page, not the console (which most users don't know about).

The nice thing about forms is they do not tie things up. A prompt stops any running script in its tracks.


#11

ok I just started the JQuery course so I was just wondering if there was a way


#12

with me just starting it I've learned the variables and they aren't much different than Javascript (other then the $ before the JQuery selections)


#13

They're called selectors, in parallel with CSS. jQuery selectors are based upon CSS.

a { }   CSS

$('a')  jQuery

The $ is actually the alias for jQuery

jQuery('a')  => longhand selector

If you check in the console after jQuery loads,

typeof jQuery  => function

A JavaScript function, in fact.

jQuery is not another language, just an abstracted form of the real language, JS. Many of the messy bits, especially around events and DOM manipulation are smoothed out with the library. To really master jQuery, we must still master JavaScript, so don't set it too far off to the side.

When a variable is written as, $my_var it is no different than my_var. The $ adds nothing of importance. It is added only to indicate that the variable references a jQuery object.

$input = $('input')   => a jQuery object

value = $input.val()  => an ordinary string object