Reputation: 11
I am working on my website. jQuery does not work on the WordPress page. Here is my code:
<script>
color = $("#colorPicker").val()
</script>
Error: Uncaught TypeError: $ is not a function`
I'm using the Header and Footer Scripts Plugin.
Upvotes: 1
Views: 44
Reputation: 337714
Wordpress jQuery installations use the jQuery
keyword instead of $
. Change your code to this:
<script>
color = jQuery("#colorPicker").val();
</script>
Alternatively, use the document.ready event handler and alias the jQuery instance passed in the argument to the function:
<script>
jQuery($ => {
color = $("#colorPicker").val();
});
</script>
Upvotes: 1