Get URL parameter and scroll to div then shake

Picture of Amitpal Singh
Amitpal Singh
March 16, 2021

$(window).on('load', function() {
$(".elementor-page-1345").each(function(){
		
		
		
			var getUrlParameter = function getUrlParameter(sParam) {
   			var sPageURL = window.location.search.substring(1),
			sURLVariables = sPageURL.split('&'),
			sParameterName,
			i;

			for (i = 0; i < sURLVariables.length; i++) {
				sParameterName = sURLVariables[i].split('=');

				if (sParameterName[0] === sParam) {
					return typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
				}
			}
			return false;
			};
		
		var faq = getUrlParameter('f');
		if(!faq == ""){
			
			$('.elementor-tab-title.elementor-active').trigger('click');
			$("#elementor-tab-title-"+ faq).trigger('click');
			customscroll(faq);
			shake(faq);
		}
	
	
		function customscroll(faq)
		{
			$('html, body').animate({   scrollTop: ($('#elementor-tab-title-'+faq).offset().top - 300)},800);
		}

		function shake(faq) {
			var div = document.getElementById("elementor-tab-title-" + faq);
			var interval = 100;
			var distance = 10;
			var times = 12;

			$(div).css('position', 'relative');

			for (var iter = 0; iter < (times + 1) ; iter++) {
				$(div).animate({
					left: ((iter % 2 == 0 ? distance : distance * -1))
				}, interval);
			}                                                                                                          
			$(div).animate({ left: 0 }, interval);
		}
	
	});
});

Share this post:

How to Attribute?

Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero.
for Example: Website, Social Media, Blogs, ebooks , newsletter, etc.
Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero.
Copied!

Got a Question? Check out our FAQ Section.

Your action, our appreciation

It encourage us to give you more valuable content on website.