How would I go about permanently add a class to a html element using jQuery.
I am planning on building a image gallery that is sorted into types/categories using the jQuery sorting plugin. I want to add a dropdown box below each image that allows the user to change the type (add/remove class) which permanently changes the HTML for next load. How would I go about this?
EDIT: Ok so from what I can put together I should use this approach:
- Jquery add/removes class.
- Send full HTML of source via AJAX request.
- PHP writes full HTML to file or is there a way to replace only a particular part of a file in PHP?
You first need to know the distinction between Client side scripting and Server side programming.
The server will return you a set of html on each response which is generated by the server side php in your case.
If you want to modify a class on a certain element, and you want this change to survive the next generated server side php response, you need to somehow inform the server of your change.
There are several options to send data from the client side to the server side.