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

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();

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.

1 Like

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

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

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

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

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

Look at the code. console .log(). It log()s to the console, 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.

1 Like

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.


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

1 Like

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)

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
1 Like