In a site I’m working on, I was using jQuery’s load() function to insert content into a div from a navigational menu. Seemed pretty straight forward. The original code looked like this:
1
2
3
4
| $(".some_class").click(function () {
var link = $(this).attr("title");
$("#div-content").load("some/path/" + link + "/index.php");
}); |
Continue reading ‘Strange jQuery.load() behavior’
Brian Glass pointed out the excellent JQuery hint plugin, which also solves the issue I wrote about recently (having text in an input field automatically disappear when you click on it).
The comment was lost because I was messing with my Disqus settings (careful, there!), but I thought it was worth pointing to; a small thing, but quite handy.
In the long run, it’s an incredible time savings not to have to re-solve these sorts of small problems every time you create a form.
I used a little jQuery last night to clear some form fields. The basic idea was, there were a couple text inputs in the form for first and last name; rather than label the fields, I made the value of each form to be initially “First” and “Last” respectively.
Then I was requested to make it so that when the field was clicked on, the word “First” or “Last” (respectively) would disappear, so that you could then proceed to enter a value without needing to highlight and delete the existing value of the text field.
It turns out that with jQuery, this is simple enough; let’s assume your field has the class “clearme”:
Continue reading ‘Clearing Form Fields with JQuery’