Problems with Javascript

Asked

Viewed 33 times

-2

Hello, I am programming my site on C9.io and I am using a cont shown here at this link: How to add +1 in a counter variable to each click?

However on C9.io in the line of Js appears $ is not definied, fix it or add global $. When I shoot the $ does not work and when I keep n of certain. How could I fix?

var count = 0;
$('#addCount').click(function(){
  alert(count);
  count++;
          <input type=button id=addCount value="Adicionar Count">

FOLLOWS THE LINK OF THE SITE https://forum-alldispor.c9users.io/index.html#/topics

  • could put snippets of codes?

  • Ready! Note: I am using Angularjs

  • and jQuery??? $ n and jQuery?

  • no, the $ is after var Count =0; which is giving not definied

  • Do not mix AngularJS and JQuery. Better try to do it with just the AngularJS or just with the JQuery

1 answer

1

Try this, now, you could use database to save the Likes! Or a system with files!

var like = $("#likes").text();

$("#addLike").click( function() {
  
$("#likes").text(like++);
  
  
  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<h2>Sistema de likes</h2>

<button class="btn" id="addLike">Like</button>

<h1 id="likes">0</h1>

  • It still seems not definied for the $

  • You imported the jQuery???

  • What do you mean? I put everything straight in the head and stuff

  • Sampaio, what if instead of Jquery/JS I sent to my MongoDB by angular would not be easier? If you saw the link of the site to understand more or less that I want this, but as I am beginner in the subject wanted to try by js and then try to send to my bank

  • I really don’t know, I’ve never used mongoDB or Angular, so I can’t help you

  • I joined your site and does not give this error! what gives on the bootstrap

  • Exactly, no error appears! :/

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.