[jQuery] tabs plugin with ajax support and callbacks
hi I've been using the tabs plugin for a while, I just updated to use the new ajax support. Works nice. Now I want to add a callback whenever a tab is updated: $(.tabs).tabs( { remote: true, loadingClass: 'progress', callback: function () { alert( 'done'); } } ); but the callback function is never actually called. any ideas why? thanks Daniel -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] tabs plugin with ajax support and callbacks
thanks! that works now. On 2/11/07, Klaus Hartl [EMAIL PROTECTED] wrote: Daniel McBrearty schrieb: hi I've been using the tabs plugin for a while, I just updated to use the new ajax support. Works nice. Now I want to add a callback whenever a tab is updated: $(.tabs).tabs( { remote: true, loadingClass: 'progress', callback: function () { alert( 'done'); } } ); but the callback function is never actually called. any ideas why? thanks Daniel Just replace callback with onShow. That had been changed a while ago. -- Klaus ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] Fwd: can't get accordion to work
duh ... there was a dumb li left in there. However, that wasn't the problem - the source validates, but no accordion. anyone have any ideas what I might check? -- Forwarded message -- From: Daniel McBrearty [EMAIL PROTECTED] Date: Jan 17, 2007 11:52 PM Subject: Re: can't get accordion to work To: jQuery Discussion. discuss@jquery.com additionally, I threw some alert boxes into the accordion source, to see if the code is actually getting there (haven't quite got the hang of firebug yet ... ) // create private scope with $ alias for jQuery (function($) { alert(here); // this fires // save reference to plugin method var plugin = $.fn.Accordion = function(settings) { alert(or here); // so does this ... yet still no accordian ... On 1/17/07, Daniel McBrearty [EMAIL PROTECTED] wrote: hi, I am trying to get this to fire, but no joy ... My code is very similar to the example code: div class=tx_acc h3sitetext/h3 pto do/p pdone/p /li h3phrases/h3 /div . . . $(function() { $(.tx_acc).Accordion(); }); but nothing happens. Just a plain set of h3's/paras. If I change to $(function() { $(.tx_acc).hide(); }); this works, so I know we are selecting. The Accordion library is definitely there, I include it after jquery itself, before the code where I initialise. I can get it and see it with the browser. what else can I check? using Firefox 1.5 under Ubuntu. -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] can't get accordion to work
OK, I found the problem, I think. It seems that the accordion feature does not work if the div is enclosed in another div. Is this limitation unavoidable? Or is this a bug? At least it should be documented, I think. (I also posted a comment at the authors site about this) thanks On 1/18/07, Daniel McBrearty [EMAIL PROTECTED] wrote: duh ... there was a dumb li left in there. However, that wasn't the problem - the source validates, but no accordion. anyone have any ideas what I might check? -- Forwarded message -- From: Daniel McBrearty [EMAIL PROTECTED] Date: Jan 17, 2007 11:52 PM Subject: Re: can't get accordion to work To: jQuery Discussion. discuss@jquery.com additionally, I threw some alert boxes into the accordion source, to see if the code is actually getting there (haven't quite got the hang of firebug yet ... ) // create private scope with $ alias for jQuery (function($) { alert(here); // this fires // save reference to plugin method var plugin = $.fn.Accordion = function(settings) { alert(or here); // so does this ... yet still no accordian ... On 1/17/07, Daniel McBrearty [EMAIL PROTECTED] wrote: hi, I am trying to get this to fire, but no joy ... My code is very similar to the example code: div class=tx_acc h3sitetext/h3 pto do/p pdone/p /li h3phrases/h3 /div . . . $(function() { $(.tx_acc).Accordion(); }); but nothing happens. Just a plain set of h3's/paras. If I change to $(function() { $(.tx_acc).hide(); }); this works, so I know we are selecting. The Accordion library is definitely there, I include it after jquery itself, before the code where I initialise. I can get it and see it with the browser. what else can I check? using Firefox 1.5 under Ubuntu. -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] what's the difference betweendocument.getElementById('id') and $('#id') ?
thanks Aaron, Michael! that makes it clear. On 1/16/07, Michael Geary [EMAIL PROTECTED] wrote: Now that it is laid out in front of me it's pretty obvious, but when you come into the thing cold, these things are not obvious. I think it would be a good idea to explicitly state what the object is, and that $ refers to it (I think that's right ... now I mention it I'm not quite sure if $ is an object reference or an operator ... ) - anyhow just a bit of clarification of the basics. It's neither of the above. :-) $ is not an operator. In JavaScript, the $ character can be used in names in the same way as a letter. $ is also not a jQuery object or a reference to one. at all. It is a *function* that returns a jQuery object. A good way to think of the $ function is that it's just like a constructor function (e.g. Date or Array), except you don't use the new operator with it, you just call it. Consider this code: // Give the $ function a more self-explanatory name var createQueryObject = $; // Create a query object for a specified query string var myQueryObject = createQueryObject('#test'); // Call a method of the query object myQueryObject.hide(); That is the same as: $('#test').hide(); Note also that $ and jQuery (used as a name in JavaScript code) are the same thing. So you could also write this code as: jQuery('#test').hide(); Or: var myQueryObject = jQuery('#test'); myQueryObject.hide(); -Mike ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] can't get accordion to work
hi, I am trying to get this to fire, but no joy ... My code is very similar to the example code: div class=tx_acc h3sitetext/h3 pto do/p pdone/p /li h3phrases/h3 /div . . . $(function() { $(.tx_acc).Accordion(); }); but nothing happens. Just a plain set of h3's/paras. If I change to $(function() { $(.tx_acc).hide(); }); this works, so I know we are selecting. The Accordion library is definitely there, I include it after jquery itself, before the code where I initialise. I can get it and see it with the browser. what else can I check? using Firefox 1.5 under Ubuntu. -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] can't get accordion to work
additionally, I threw some alert boxes into the accordion source, to see if the code is actually getting there (haven't quite got the hang of firebug yet ... ) // create private scope with $ alias for jQuery (function($) { alert(here); // this fires // save reference to plugin method var plugin = $.fn.Accordion = function(settings) { alert(or here); // so does this ... yet still no accordian ... On 1/17/07, Daniel McBrearty [EMAIL PROTECTED] wrote: hi, I am trying to get this to fire, but no joy ... My code is very similar to the example code: div class=tx_acc h3sitetext/h3 pto do/p pdone/p /li h3phrases/h3 /div . . . $(function() { $(.tx_acc).Accordion(); }); but nothing happens. Just a plain set of h3's/paras. If I change to $(function() { $(.tx_acc).hide(); }); this works, so I know we are selecting. The Accordion library is definitely there, I include it after jquery itself, before the code where I initialise. I can get it and see it with the browser. what else can I check? using Firefox 1.5 under Ubuntu. -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] what's the difference betweendocument.getElementById('id') and $('#id') ?
yes. Thanks. I have it now. Any takers on my what is the jQuery object question? Is it simply an array of elements that have been selected? It may be kind of obvious, but it took me a few days to figure it. It might be good to explicitly say this somewhere early in the docs IMHO. thanks again. On 1/15/07, Dave Methvin [EMAIL PROTECTED] wrote: $(function () { self.focus(); $(#userresponse).setAttribute(autocomplete,off); $(#userresponse).focus(); }); I would do this: $(function () { self.focus(); $(#userresponse).attr(autocomplete,off)[0].focus(); }); There isn't a setAttribute method on a jQuery object, and I assume you want the DOM focus() method on #userresponse. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] what's the difference between document.getElementById('id') and $('#id') ?
thanks very much everyone for helping clarify things. This helps a lot. Yes, it was using firebug that helped me to start figuring what was going on. May I suggest that some extracts of this thread, or whatever, find their way into the getting started docs? It could maybe be just a paragraph or two. Now that it is laid out in front of me it's pretty obvious, but when you come into the thing cold, these things are not obvious. I think it would be a good idea to explicitly state what the object is, and that $ refers to it (I think that's right ... now I mention it I'm not quite sure if $ is an object reference or an operator ... ) - anyhow just a bit of clarification of the basics. The reason I like jQuery very much, is because my needs are simple, and I got it doing useful things very quickly - at the same time it doesn't seem at all restricted as the plugin architecture promises that more advanced things are also there. Just a little extra explanation would really be the icing on the cake, I think. On 1/16/07, Yehuda Katz [EMAIL PROTECTED] wrote: There's a reasonable explanation of the jQuery object in the Visual jQuery Magazine at http://www.visualjquery.com/magazine/issue1.01.pdf On 1/16/07, PragueExpat [EMAIL PROTECTED] wrote: Thanks for the explaination. The reason for my request was my curiosity of what exactly makes up the JQuery Object. For example, I didn't understand that [0] is a reference to the first DOM object. I ran this to try to look at the Object (using 1.04): --- html head script type=text/javascript src=jquery.js/script /head body form input id=test class=test type=text nametest input id=test2 class=test type=text nametest /form script type=text/javascript !-- $(document).ready(function(){ var t = $(.test); var s; for (property in t) { s = s + brbrhr /brbr +property.toString()+ : +t[property].toString(); } document.write(s.toString()); }); //-- /script /body /html --- and learned quite a bit. (Although the page never fully loads, not sure why). Anyway, I would recommend looking at this page for anyone who wants to learn more. (If there is a better way to look at the Object, please post here) - Rich malsup wrote: I second the request for a good understanding of what the JQuery object is. The jQuery object is just a JavaScript object (like Date or Array). It encapsulates zero or more DOM elements and lets you manipulate those elements using the jQuery API. var jq = $('.myClass'); The statement above selects all elements that have a class of 'myClass' and wraps them in an object - the jQuery object. Once those elements are wrapped in a jQuery object you can use the jQuery API to do all kinds of things with them. Like show them all: jq.show(); or add a click event handler to all of them: jq.click(function() { alert ('I was clicked'); }); or access each of the selected DOM elements: jq.each(function(i) { // 'this' is the DOM element inside the 'each' method this.innerHTML = 'my index is ' + i; }); That's really the nuts and bolts of it. jQuery lets you easily select elements in the DOM and do something with them. It's selection capabilities are very powerful and very fast. And it's API is quite extensive. You'll also find that most of the functions in the jQuery API return the jQuery object on which they operate. This means they are chainable and this is great when you want to do more than one thing with the selected elements. The examples above could be combined into a single statement like this: $('.myClass').show().click(function() { alert ('I was clicked'); }).each(function(i) { this.innerHTML = 'my index is ' + i; }); Mike ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- View this message in context: http://www.nabble.com/what%27s-the-difference-between-document.getElementById%28%27id%27%29-and-%24%28%27-id%27%29---tf3017662.html#a8391034 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Yehuda Katz Web Developer | Wycats Designs (ph) 718.877.1325 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] what's the difference between document.getElementById('id') and $('#id') ?
ok, I got it. To access the element I need to access $('#id')[0] What confused me here is that I wasn't really clear what the jquery object actually is. I have looked through the various intro and tutorial material a few times, and managed to get the library to do some useful things, but I missed this. Is there anywhere where this is explained? thanks Daniel On 1/15/07, Daniel McBrearty [EMAIL PROTECTED] wrote: sorry ... not the smartest question. of course, one returns the element, one returns the jquery object. What I needed was $('#id').attr( { autocomplete : off } ); I still have a problem to set the focus though. There is no error shown for $('#id').focus(); but the focus is not set ... On 1/15/07, Daniel McBrearty [EMAIL PROTECTED] wrote: I'm changing some old js I had to use jQuery. I used to have a function like this (to select a certain text input on a form and automatically focus on it) ... : window.onload = function() { self.focus(); document.getElementById(userresponse).setAttribute(autocomplete,off); document.getElementById(userresponse).focus(); } which worked fine ... then I replace it with this: $(function () { self.focus(); $(#userresponse).setAttribute(autocomplete,off); $(#userresponse).focus(); }); which fails to select the text box. why not? I thought these were equivalent excpet the jQuery version loads sooner? thanks Daniel -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] what's the difference between document.getElementById('id') and $('#id') ?
sorry ... not the smartest question. of course, one returns the element, one returns the jquery object. What I needed was $('#id').attr( { autocomplete : off } ); I still have a problem to set the focus though. There is no error shown for $('#id').focus(); but the focus is not set ... On 1/15/07, Daniel McBrearty [EMAIL PROTECTED] wrote: I'm changing some old js I had to use jQuery. I used to have a function like this (to select a certain text input on a form and automatically focus on it) ... : window.onload = function() { self.focus(); document.getElementById(userresponse).setAttribute(autocomplete,off); document.getElementById(userresponse).focus(); } which worked fine ... then I replace it with this: $(function () { self.focus(); $(#userresponse).setAttribute(autocomplete,off); $(#userresponse).focus(); }); which fails to select the text box. why not? I thought these were equivalent excpet the jQuery version loads sooner? thanks Daniel -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] [jquery] what if the button wasn't there when the page loaded?
suppose we have some content to a page that gets loaded via AJAX in response to some other event ... it looks like this : input type=button id=some_new_button how do I bind to this, in a simple way? $(function() { $(#some_new_button).click( function() { ... }; }); doesn't work because the button didn't happen until after the doc loaded ... any ideas? -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] [jquery] what if the button wasn't there when the page loaded?
I'm looking at http://jquery.bassistance.de/jquery-getting-started.html#rate where it says: SNIP A very common problem encountered when loading content by AJAX is this: When adding event handlers to your document that should also apply to the loaded content, you have to apply these handlers after the content is loaded. To prevent code duplication, you can delegate to a function. Example: // lets use the shortcut $(function() { var addClickHandlers = function() { $(a.clickMeToLoadContent).click(function() { $(#target).load(this.href, addClickHandlers); }); }; addClickHandlers(); }); Now addClickHandlers is applied once when the DOM is ready and then everytime when a user clicked a link with the class clickMeToLoadContent and the content has finished loading. /SNIP but I'm not quite getting to this. First I don't understand : $(#target).load(this.href, addClickHandlers); because I'm only finding docs for a load function with a single func argument ... what is this.href doing? does this mean that addClickHandlers gets called EACH time #target loads? thanks Daniel On 1/13/07, Daniel McBrearty [EMAIL PROTECTED] wrote: suppose we have some content to a page that gets loaded via AJAX in response to some other event ... it looks like this : input type=button id=some_new_button how do I bind to this, in a simple way? $(function() { $(#some_new_button).click( function() { ... }; }); doesn't work because the button didn't happen until after the doc loaded ... any ideas? -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] [jquery] what if the button wasn't there when the page loaded?
thanks ... this still isn't making any sense to me though. the docs say that load Bind a function to the load event of each matched element. IOW ... it doesn't actually load anything - it causes some function to get executed each time that element finishes loading. I believe the online docs are accurate, but load is a flexible function that you can pass one, two or three args. And href is an important one - that's what you're loading! $('#target').load('myFile.html'); so this just loads myFile without and other function getting executed? loads it where? this is an element ie a button, a link or whatever ... how can you load an html file into it? sorry if this is a dumb q ... but this completely doesn't make sense to me. If I failed to R some basic bit of TFM I'd be glad of a pointer ... thanks again. -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] [jquery] what if the button wasn't there when the page loaded?
On 1/13/07, Mike Alsup [EMAIL PROTECTED] wrote: the docs say that load Bind a function to the load event of each matched element. But if you notice, the docs indicate there is more than one load function. The one you're quoting is a bind for the load event. You're invoking a load action directly for which the docs say: ahah. silly me. I was looking under events, didn't see the one under Ajax ... http://docs.jquery.com/Events Hope this helps. it does, lots. Thanks! -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] noob q - using $().html
On 1/4/07, Karl Swedberg [EMAIL PROTECTED] wrote: I should have mentioned that I changed the HTML as well. I added an ID to the submit button (submit-member). Notice how the event is being triggered now: $('#submit-member').click(function() {...}); yes, I have that, and the event is happening - I can fire an alert or set the html to a fixed string OK. Since var username = $(this).prev().val() is appearing inside the click method, $(this) refers to the submit button, prev() refers to the previous sibling of that button, which should be the text input, and val() refers to the value of that text input. That's what I figured, but it doesn't seem to work. I always get null. I'm trying to figure it out using FireBug and alert boxes and so on. I realise this is not really a jquery issue though ... I think. More my (lack of) knowledge about the DOM and js. Now I'm wondering, though, what you're trying to accomplish with the code. As Doug noted, it doesn't look like you really need a form at all to do what you're trying to do. But it's kind of hard to advise on that without knowing the larger context. The context is that indeed, I don't need the submit behaviour here - this is some admin code of my site, and I know I will always use firefox and have javascript turned on. SO it's a good place to start using some js/ajax techniques without yet worrying about how to make things work for other browsers and users without js. Once I have the text input being captured OK in the click method, I will use it in a server call and then use it to set the html. one step at a time though ... -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] noob q - using $().html
and yes, I've gone over to using a button type, and will likely cut out the form tags too. thanks for that suggestion Doug. -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] noob q - using $().html
OK, I've fixed it. I also had a table which was used to align elements which I had omitted for clarity. I looked up prev(), and saw that it looks for the unique previous element ... removed the table and all is OK. My code us now this: (in myapp.js ) $(document).ready(function() { $('#find_member_button').click(function() { var username = $(this).prev().val(); $(#member_info).html(username); return false; }); }); (in the html ) p id=member_info/p input type=text size=30 id=username input type=button id=find_member_buttonsize=30 value=Find by Username which is WAY cleaner. Thanks. I learned a few things :-) On 1/4/07, Daniel McBrearty [EMAIL PROTECTED] wrote: and yes, I've gone over to using a button type, and will likely cut out the form tags too. thanks for that suggestion Doug. -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] noob q - using $().html
Hi Just getting into using js to do things. I'm just experimenting right now. Here is my example code: p id=member_info/p script type=text/javascript function findMember(form){ $(#member_info).html(form.username.value); } /script form name=find_member action= method=GET input type=text size=30 name=username input type=submit onClick=findMember(this.form) size=30 value=Find by Username /form now what happens when I fill in a value and click is that the value I entered into the text box appears in the member_info p ... but disappears again almost straight away. any ideas? thanks. the lib looks nice and clean BTW. Daniel -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] noob q - using $().html
thanks a lot guys. That 's really a great response. I got it to basically work, now I'll read through your suggestions and clean it up. I'm still learning ... :-) thanks again. Daniel On 1/4/07, Karl Swedberg [EMAIL PROTECTED] wrote: Okay, so Mike and Blair got back to you before I could, but I'm going to answer anyway. They're right, of course, that you need to return false, because you want to stop the default action. One of the great things about jQuery is that it lets you easily separate behavior from content. So I would suggest pulling the onclick handler out of the input. Here is what it would look like with the script in the head, but ideally you should put it in another file and include it the same way you include jquery.js: html head script src=scripts/jquery.js type=text/javascript/script script type=text/javascript charset=utf-8 $(document).ready(function() { $('#submit-member').click(function() { var username = $(this).prev().val(); $(#member_info).html(username); return false; }); }); /script /head body p id=member_info/p form name=find_member action= method=GET input type=text size=30 name=username input type=submit id=submit-member size=30 value=Find by Username /form /body /html You should also put DTD, etc. in there. I'm just taking shortcuts for the sake of brevity. --Karl _ Karl Swedberg www.englishrules.com www.learningjquery.com On Jan 3, 2007, at 7:37 PM, Daniel McBrearty wrote: Hi Just getting into using js to do things. I'm just experimenting right now. Here is my example code: p id=member_info/p script type=text/javascript function findMember(form){ $(#member_info).html(form.username.value); } /script form name=find_member action= method=GET input type=text size=30 name=username input type=submit onClick=findMember(this.form) size=30 value=Find by Username /form now what happens when I fill in a value and click is that the value I entered into the text box appears in the member_info p ... but disappears again almost straight away. any ideas? thanks. the lib looks nice and clean BTW. Daniel -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] noob q - using $().html
html head script src=scripts/jquery.js type=text/javascript/script script type=text/javascript charset=utf-8 $(document).ready(function() { $('#submit-member').click(function() { var username = $(this).prev().val(); $(#member_info).html(username); return false; }); }); /script /head Ok, I'm looking at this. I moved the js into a seperate file. I am calling the function OK when the button is clicked. But something seems wrong with var username = $(this).prev().val(); which is ending up as undef. I don't actually understand this line - how is it getting the value out of the form? this seems to be the button itself. I also tried something like var username = $(#username).val(); to try to select the text box directly and get the value, but no joy either. thanks again ... gonna sleep now :-) -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/