[jQuery] Re: value of
Try with $("a").html() El 10/10/2007, a las 8:57, Sharique escribió: What I want to is :When user click on a link it will show text inside the tag. (ie. when user click in "more" it will show "more" in alert.) I have following code : - http://www.w3.org/ TR/html4/strict.dtd"> jq test $(function() { $("a").click( function( ) { alert($("a").val()); // shows error }); }); tata test more --- When I run this code it shows following error. TypeError: this[0].value has no properties at anonymous(void) (test/jq/js/jquery.js:335) at anonymous() (test/jq/alinks.htm:13) at anonymous(Object) (test/jq/js/jquery.js:1776) at anonymous() (test/jq/js/jquery.js:1620) -- Juan G. Hurtado [EMAIL PROTECTED]
[jQuery] Re: Plugin's method called chained with selector or not?
Hi Michael, El 01/08/2007, a las 10:26, Michael Geary escribió: You probably shouldn't be making direct calls to a $.fn.methodName () function. I'm not sure what it is you want to accomplish, but perhaps a good example would be the "each" function. There is a $.fn.each which is called when you use $('.foo').each(). And there is a separate $.each that is meant to be called directly. In fact, $.fn.each calls $.each to do the iteration. Maybe you could use a pattern like that: Define a jQuery.methodName function for direct calls, and a jQuery.fn.methodName for calls via a jQuery object - which can use jQuery.methodName as a support function if that makes sense. I am writing little plugins for helping me in my developments. Everything's ok, and easy to do, but now I'm face to face with a little problem. I've a plugin's method like this: [CODE] jQuery.fn.methodName = function(options) { // Code } [END CODE] The problem is that I want to know when I call the function this way: [CODE] $('elemento.class').methodName(); [END CODE] And when I call it this other way: [CODE] $.fn.methodName(); [END CODE] I need this in order to do the "this.each" thing inside the plugin's method. First of all, thank you very much for your answer, it really make sense. I'm gonna test it right now, because it really seems to be the obvious way to do it. Thanks again. -- Juan G. Hurtado [EMAIL PROTECTED]
[jQuery] Plugin's method called chained with selector or not?
Hi everyone, I am writing little plugins for helping me in my developments. Everything's ok, and easy to do, but now I'm face to face with a little problem. I've a plugin's method like this: [CODE] jQuery.fn.methodName = function(options) { // Code } [END CODE] The problem is that I want to know when I call the function this way: [CODE] $('elemento.class').methodName(); [END CODE] And when I call it this other way: [CODE] $.fn.methodName(); [END CODE] I need this in order to do the "this.each" thing inside the plugin's method. Hope everything is well explained, and sorry about my poor english. Thanks in advance. -- Juan G. Hurtado [EMAIL PROTECTED]
[jQuery] Re: Newbie "Parent" question
I think you should use "parent" as a function, with the (): alert($(this).parent().attr('class')); El 25/05/2007, a las 14:12, Matt W escribió: Hi folks, I started working with jQuery for the first time yesterday- and I've got something that I'm hoping you all may be able to help me figure out. I would think that this (simple?) bit of code would 1) find all the tags with class "addcomment", and then 2)assign an onClick that would create an alert box displaying the class of the containing block. But the second to last line with the alert doesnt seem to be working. Any help is appreciated. Thanks, Matt $("a").filter(".addcomment").click(function() { alert($(this).parent.attr('class')); });