Category: jQuery Code Snippets

Ajax requests with jQuery.post()

This is one of the reasons I still like jQuery. I’m sure all the new frameworks do similar stuff, but things like this are so simple with jQuery. Anyway, jQuery.post() is a shorthand Ajax function. It’s the equivalent of doing this: $.ajax({ type: “POST”, url: url, data: data, success: success, dataType: dataType }); So, with it, you can send an Ajax request this easily: var posting = $.post(url, data); Then, handle the response like this: posting.done(function(data) { // Handle data here }); Or, all together like this: $.post( “process.php”, function( data ) { $( “.result” ).html( data ); }); It

Read More »

jQuery Smooth Scroll to Anchor Using animate()

I always get a kick out of jQuery… especially animation methods. It’s one of those things that just wows clients… and truthfully, I feel pretty cool watching the animations run on a site. That said, much of what you can do with jQuery animations is more than “eye-candy”… they help enhance the user experience. This is one such animation: smoothing scrolling to an anchor tag. Instead of that abrupt flash you get as default behavior in a browser… you get a nice smooth scroll that gives a site visitor some context about what they just clicked and where they’re ending

Read More »

jQuery: Find An Anchor By Its HREF

jQuery selectors can be a bit tricky. :first-child, :last-child, nth-of-type, is it zero-based, why is it grabbing that element when I expected this one. Fun stuff. On a recent project, I needed to find an anchor tag by its href so I could then replace it with my own URL… and that got me thinking about jQuery selectors again. So, let’s run through some and try to clear up some confusion. Here’s this week’s Tech Tutorial: And, if you’d give me a likey-like I’d sure appreciate it! And like I said the source code is available on Patreon for the smart folks who

Read More »

Add Active Navigation Class to Menu Item Based on URL Using jQuery

In this jQuery tutorial, you’ll learn how to add an active class to a menu item based on the page URL using jQuery… so you can highlight that menu item. You’ll learn: how use the jQuery addClass() method how to get the current page’s URL path in JavaScript how to split a URL in an array of parts how to use the JavaScript pop() method how to target an element based the value of a specified attributed using jQuery Watch the tutorial below: Links mentioned in the video: Link to the Complete Web Developer Course with discount. My web developer

Read More »

Set DIV Height to 100% of Its Parent Using jQuery

In this jQuery tutorial, you’ll learn how to set the height of a DIV to 100% of its parent. You’ll learn: how to set variables and target selectors how to get and set div height using height() how to target multiple selectors at once Watch the tutorial below: Links mentioned in the video: Link to the AJAX course mentioned My web developer resources page with more code snippets Here’s the code I used in the video: If you get value from this code snippet, please consider sharing it with another developer or group who could benefit from it.

Read More »

jQuery Tutorial: How to Build a jQuery Accordion

In this jQuery tutorial, you’ll learn how to build a jQuery accordion. You’ll learn: how to slideUp() and slideDown() different elements how to use relative selectors to target elements in jQuery how to use the click event to trigger functionality on click Watch the tutorial below: Links mentioned in the video: Link to the AJAX course mentioned My web developer resources page with more code snippets Here’s the code I used in the video: If you get value from this code snippet, please consider sharing it with another developer or group who could benefit from it.

Read More »

jQuery Tutorial: Submit a Form and Post Data Using jQuery and AJAX

In this jQuery tutorial, you’ll learn how to submit a form, post the data and format the response using jQuery and AJAX: Here’s the code I used in the video: Index.php Process.php If you enjoyed this tutorial and want to keep learning, check out my free tutorial site here: https://johnsfreetuts.com

Read More »

The simple secrets to high-paying freelance clients

What makes clients willing to pay $5,000, $10,000 even $20,000 and up for your services? Download and install my mobile app and I’ll show you. It’s free. Just click the button below:

Clients Like:

Inc. Magazine Logo
Lewis Howes Logo
Ray Edwards Logo

WHAT OTHERS ARE SAYING

Jim DeJonge

Jim DeJonge

John has a relaxed and engaging manner. His advice is solid and the explanations are well thought out.

Lori Grant

John did an outstanding job on my project. I highly recommend him and look forward to working with him on future projects.

Steve Dimmick

Steve Dimmick

John has provided expert knowledge and advice on multiple occasions that have helped me better serve my clients. John is a Rockstar!

Bob Patterson

Not only is John a very talented programmer and developer, he is also an excellent communicator. He has a talent for taking complex subjects and communicating them in terms that anyone can understand. This is a rare combination. This ability has enabled me to take my skills and knowledge to the next level. Thank you John for for all that you do.

Lewis Howes

John is amazing at building membership sites. He converted one of my sites over from it’s existing (hardly working) platform over to the clean and simple to use WishList membership platform. I highly recommend using John and WishList for any of your membership site needs.

Sukh Plaha

John is a fantastic and patient tutor, who is not just able to share knowledge and communicate it very effectively – but able to support one in applying it. However, I believe that John has a very rare ability to go further than just imparting knowledge and showing one how to apply it. He is able to innately provoke one’s curiosity when explaining and demonstrating concepts, to the extent that one can explore and unravel their own learning journey. Thanks very much John!

Bradley Smith

John and I have worked together on numerous projects. John is very quick and efficient and was a pleasure to work with.

Daniel Mohlendick

On the Freelancing on Upwork course: “This is by far the best course i have watched on Skillshare!! Thank you so much.”

Chris Aitken

He significantly improved my site through his expert knowledge of PHP, CSS and Javascript. Would definitely recommend John to others.

Thabo Motsoahae

John is one of the best instructors I have come across, I learned a lot from his online tutorials.

Oliver Wainwright

Oliver Wainwright

I’m a fan. I have completed several of John’s courses. I find him very knowledgeable and he has a great delivery.

Ray Edwards

I recommend John every chance I get. If every person I worked with were as committed to excellence, punctuality, value, and unquestionable integrity… the world would be a better place. Highest recommendation.

Andrew Malone

Andrew Malone

John Morris is exceptional in his ability to give focused insight into Freelancing and starting one’s business. His direct methods inspire confidence in his honesty.