Do I have these both set up correctly?

onclick="document.getElementById('player').volume=1.0;player.play()"

onclick="document.getElementById('player').volume=1.0;player.paused ? player.play() :player.pause()"

Do you have them set up correctly? That’s a good question. What are you wanting to achieve, and do you have a sample page to help us test your situation?

I know the codes work, I just want to know if their written correctly.

What do you mean by correctly? Correctly according to the ECMAScript 5 specifications, correctly according to jslint.com, or correctly according to each of our own personal coding standards? Or some other kind of correctly?

1 Like

I asked about that in another post if there was a javascript checker.

Only you are likely to have seen all of your other threads. Can you please provide more detail for this thread?

It’s telling me this?

Expected ‘/’.

<button onclick="document.getElementById('player').volume=1.0;player.play()"></button>

<button onclick="document.getElementById('player').volume=1.0;player.paused ? player.play() :player.pause()"></button>

[quote=“asasass, post:7, topic:230014, full:true”]
It’s telling me this?[/quote]

What is telling you that?

jslint.com is only for JavaScript. It doesn’t do HTML.

That is only one of the many reasons why it’s better to keep your HTML, your CSS, and your JavaScript separate from each other.

Is there such think as an inline javascript checker?

Such as http://www.javascriptlint.com/online_lint.php ?

It’s telling me this is an error which makes no sense.
<
^
SyntaxError: syntax error

it’s trying to tell you that the HTML code needs to be contained within an HTML tag.

it is

<button onclick="document.getElementById('player').volume=1.0;player.play()"></button>

<button onclick="document.getElementById('player').volume=1.0;player.paused ? player.play() :player.pause()"></button>

This works: When I removed a question mark or a period, it told me error.
https://html5.validator.nu/

Yes indeed - and the linter is telling you that <button is not good to start with.

The validator only tells you that you have valid syntax. It doesn’t lint or tell you anything about preferred ways to code.

That’s exactly how it’s set up here:

That is an excerpt - it is not a full HTML page. All HTML should be contained within HTML tags. Do I need quote from the HTML specs for you to understand this, or are you willing to accept that some of us here can advise on this topic pretty well.

1 Like
 <!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>

<button onclick="document.getElementById('player').volume=1.0;player.play()"></button>
<button onclick="document.getElementById('player').volume=1.0;player.paused ? player.play() :player.pause()"></button>
</body>

</html>