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

Introduction

If you are having trouble getting your jQuery code to work, you are not alone. Many developers have experienced the same issue. Fortunately, there are a few steps you can take to troubleshoot and resolve the issue. In this article, we will discuss the common causes of jQuery not “throwing” anything and how to fix them. We will also provide some tips on how to prevent this issue from occurring in the future. By the end of this article, you should have a better understanding of why your jQuery code isn’t working and how to fix it.

Solution

The most likely cause of this issue is that you have a syntax error in your jQuery code. Check your code for any typos or incorrect syntax and make sure that all of your brackets, parentheses, and quotation marks are properly closed. Additionally, make sure that you are using the correct version of jQuery for the version of your browser.

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

If you’re having trouble getting your jQuery code to “throw” anything, there are a few things you can try to get it working again. First, make sure you’re using the correct syntax for the version of jQuery you’re using. Different versions of jQuery have different syntax, so if you’re using an older version, you may need to update your code to the latest version.

Next, check to make sure you’re including the jQuery library in your HTML page. If you’re not, you won’t be able to use any of the jQuery functions. To include the library, add the following line of code to the section of your HTML page:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

Finally, make sure you’re using the correct selector for the element you’re trying to target. If you’re not using the correct selector, jQuery won’t be able to find the element you’re trying to target.

If you’re still having trouble getting your jQuery code to “throw” anything, you may want to try using a debugging tool such as Firebug or Chrome DevTools. These tools can help you identify any errors in your code and help you get your jQuery code working again.

By following these steps, you should be able to get your jQuery code working again and get it “throwing” the results you’re looking for. Good luck!