[Solved] My Jquery isn’t “throwing” anything


I see four things in your code:

  1. Don’t forget the ; at the end of your jquery click event definition.

  2. You should use #someDiv instead of .someDiv as someDiv is an Object Id, not a Object class. This was already mentioned by Wesley.

  3. You can’t use this.val() since val() is not a native javascript function. You may want to use $(this).val() which is wrapping the javascript object into jQuery.

  4. You need to use $(function() { /* your code */ }); as your javascript function is defined before your HTML object will be created. This is a shortcut for
    $(document).ready(function () { /* your code */ });

It would be:

<script type="text/javascript">
$(function() {
  $('.hover-star').click(function (){
    $('#someDiv').text($(this).val());
  });
});
</script>

4

solved My Jquery isn’t “throwing” anything