$ not defined issue

$(document).ready(function() {
	var oldId = null;

	$('.pt_tabs__controls__link').click(function(e) {
		e.preventDefault();

		if ($(this).hasClass('pt_tabs__controls__link--active')) {
			return false;
		}

		var currentId = parseInt($(this).data('id'), 10);
		$('.pt_tabs__controls__link--active').removeClass('pt_tabs__controls__link--active');
		$(this).addClass('pt_tabs__controls__link--active');

		if (currentId < oldId) { // item is hidden
			var timing = $('.card.hidden').length * 100;
			$('.card').each(function(index) {
				if (index > (currentId - 1 ) || index == (currentId - 1)) {
					window.setTimeout(function() {
						$('.card').eq(index).removeClass('hidden');
					}, timing - (index * 100));
				}
			});
		} else {
			$('.card').each(function(index) {
				if (index < (currentId - 1)) {
					window.setTimeout(function() {
						$('.card').eq(index).addClass('hidden');
					}, index * 100);
				}
			});
		}

		oldId = currentId;
	});
});

This line is generating $ not defined issue where am I going wrong?

$('.pt_tabs__controls__link').click(function(e) {

Typically that error is because the “$” is meant to be jQuery, but jQuery has not been pulled in before the the code that needs it tries to run.

So my guess is you either forgot to include jQuery or you put the <script> tags in the wrong order.

1 Like

J query is working rest of the JQUERY code is working. In fact wordpress automatically loads JQUery.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.