This post will look at rendering part of a page in a CakePHP application with an Ajax and jQuery. This technique can be employed in a number of situations. It’s particularly useful for loading (or refreshing) parts of a page that need to communicated with a controller and in turn a model. Another use is […]
jQuery
Media Events jQuery
A common thing to want to do is respond to the state of some media (audio of video) playing on your page. You can “hook” into a number of events on the media object, like when the video is playing, when it is paused, even find out the current time of the video. However, we’ll […]
jQuery Scroll Event
The jQuery scroll event works just the .click() event, the main difference is that we usually want to bind it to the whole document (the webpage) rather than a specific div or img tag. So the event declaration will look like this:
1 2 3 4 5 |
$(document).scroll(function() { //All your code will go here... }); |
Note: This should be within the document ready function. In this function, […]
jQuery Change Image
Changing an image in jQuery is pretty straight forward. First of all, you need an image to change. This is just a usual html image in your page with an id on it:
1 2 3 |
<img id="my-image" src="images/image-name.jpg"> |
We know that the image being displayed comes from the “src” attribute of the image tag, so this is what we […]
jQuery Intro
In your scripts file, you should always start with the following:
1 2 3 4 5 |
$(document).ready(function(){ //Everything else should go in here... }); |
This makes sure your page is fully loaded before any further interaction takes place. Selectors Selectors are how you select what element on your page that you want to “interact” with (element referring to the part of you HTML, an image for example). […]