That would be a bad idea. What if "span.tagvalue" hasnt loaded yet?
$(function(){ ... }); is a shortcut for $(document).ready(function(){ ...
});
On 12/8/06, Jonathan Sharp <[EMAIL PROTECTED]> wrote:
You can also prune the outter $(function(){ ... }); call
So...
$("span.tagvalue").click(function() {
$(this).addClass("clicked");
});
-js
On 12/8/06, Peter Bengtsson <[EMAIL PROTECTED]> wrote:
>
> Here's the code that doesn't work. Can someone point me in the right
> direction?
>
> $(function(){
> $("span.tagvalue").click(function() {
> // ...do other stuff...
>
> // add "clicked" as class now that it's been clicked
> this.addClass("clicked"); // THIS DOESN'T WORK
> });
> });
>
> This doesn't work because 'this' is not a jQuery object I guess. How
> sould I do this then?
>
> --
> Peter Bengtsson,
> work www.fry-it.com
> home www.peterbe.com
> hobby www.issuetrackerproduct.com
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/