Uncaught TypeError: $ is not a function – Magento 2

Use Jquery code the following way in Magento 2

<script>
require([
‘jquery’
], function ($) {
$(function () {

// Write code here

});
});
</script>