So I am using a wordpress theme called : thalassa.
I went to this site and copied the portfolio.js code. (note: my portfolio.js is exactly the same except the first line)
portfolio.js :
$(window).load(function() {
/* ================ VERFIFY IF USER IS ON TOUCH DEVICE ================ */
if(is_touch_device()){
$(".portfolio-image").on('click', function(e){
$(this).find('.portfolio-hover').show();
});
}
// function to check is user is on touch device
function is_touch_device() {
return 'ontouchstart' in window // works on most browsers
|| 'onmsgesturechange' in window; // works on ie10
}
/* ================ PORTFOLIO ISOTOPE FILTER ================ */
(function() {
//ISOTOPE
// cache container
var $portfolioitems = $('#portfolioitems');
// initialize isotope
$portfolioitems.isotope({
filter: '*',
masonry: {
columnWidth: 1,
isResizable: true
}
});
// filter items when filter link is clicked
$('#filters a').click(function() {
$('#filters li').removeClass('active');
var selector = $(this).closest('li').addClass('active').end().attr('data-filter');
$portfolioitems.isotope({
filter: selector
});
return false;
});
})();
});
Then I paste it into my own site and it says : $ is not a function.
Why does it work on that site and not on my site? What am I doing wrong? Before I added
$(window).load(function() {
I had
jQuery(document).ready(function($) {
It works but sometimes it bugs out. And on the site I linked it doesn’t.
DO it like this way,
});
This function is depreciated, you can use :
Please use jQuery word insted of $ in wordpress.