So i wanted to make some pretty buttons like http://www.oscaralexander.com/tutorials/how-to-make-sexy-buttons-with-css.html and everything is working fine. I wanted my forms to be able to be submitted with these sexy buttons.
So i started to use jQuery to handle all my “a” click actions.
$(document).ready(function() {
$("a").click(function() {
alert("a");
var a = $(this);
var id = a.attr("id");
switch (id) {
case "formSubmit":
a.parents("form:first").submit();
return false;
});
one more question… How do i get that code above to be highlighted in javascript? or any code like formating? Sorry for the crappy spaces, the second i find out how, i will edit it.
I got distracted and forgot to ask the original question. Now with jQuery it is easy to add in new information through $.post and other information. HOW do i add in a new a href link so that the $("a").click catches it?
Use a
.live()handler to handler clicks on new and future elements by replacing this:With this:
This way a handler on
documentlistens for clicks from<a>elements to bubble up…which happens for current and new elements.