Hi There
I'm a new jQuery convert, been using MooTools for several years now and felt it was about time I made the switch.
I have a query regarding use of the class selector and its possible limitations. I'm writing an auto-clear function and basically what I want to do is cycle through all the input fields with a class of .autoclear and add the initial value to the element as stored data. Now I know I can do this:
- $('.autoclear').each(function(index, item){
- $(this).data('initVal', $(this).val());
- });
But I was wondering if there was an easier one line way to do this along the lines of:
- $('.autoclear').data('initvalue', $(this).val());
I've tried the one line version as above and it doesn't work so if someone can let me know if this is possible and what the correct syntax would be that would be great. Thanks in advance
