I am completely new to coding in general. I started with the very foundations of HTML, CSS and JavaScript.
I have two paragraphs:
<p id="title1">Change this</p>
<p id="title1"> Change this too! </p>
While the first automatically changes:
<script type="text/JavaScript">
$('#title1').html('Changed!');
</script>
second no. But right? Since everyone is #title1changing?
I have the same problem for the version onclick. The first paragraph changes when you click on it, the second - no.
<p id="title3" onclick="sayGoodbye();">Toggle this Hello - Goodbye</p>
<p id="title3" onclick="sayGoodbye();">Thing to click on</p>
<script type="text/javascript">
function sayGoodbye(){
$("#title3").html('Goodbye');
$("#title3").click(function(){
$("#title3").html("Hello again!");
$("#title3").off("click");
});
}
</script>
source
share