Re: [jQuery] Once I've downloaded it...
I'd read the "Getting Started" section at http://docs.jquery.com/Main_Page . On Fri, Jan 15, 2010 at 9:06 AM, Jerry wrote: > I'm a newbie and have been informed that I need to become familiar > with jQuery. I have downloaded it from the download page. What do I > do with it, now? > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Sceptic about JQuery
On Wed, Jan 13, 2010 at 9:11 AM, olliewebster wrote: > Hi, > I recently came across JQuery, but I'm not sure weather I should use > it. Even though I already know JavaScript, would I have to learn a new > language specific to JQuery? What would the advantages of using JQuery > be? Finally, would it be hard to install? > Thanks > I like to think I'm fairly competent ant JavaScript, and for the longest time, I put off learning jQuery because really... why invest the time to learn a different way to write stuff I already know how to write? Then I saw this: $('#element').toggle(); That right there is the same as: if (document.getElementById('element').style.display == "none") { document.getElementById('element').style.display = "block"; } else { document.getElementById('element').style.display = "none"; } As you can see, that's code to toggle the display of an element. If it's hidden, show it. If it's visible, hide it. Let's say you wanted to trigger that based on a button click. Normally, you'd have In jQuery, your script is completely unobtrusive and should never show up in the HTML itself. In jQuery, that same click would be up int he script area: $('#myButton').click(function() { $('#element').toggle(); }); So, as you can see... yes, it's taking the time to learn a new way to do what you already know how to do... but it's a way that will save you a ton of time. I've changed the behaviors of HTML pages entirely without ever touching the .html file (all done in the .js). If it takes you a week to grok the basics (because you'll probably always be "learning")... you'll make up that week in no time just by virtue of never having to type document.getElementById() again :) "Installing" jQuery is simply a link to the jQuery.js file. If you're storing it locally, it's . You can also point to google's repository where they host the jQuery file (as well as other libraries). http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js</a> "> Add the line above, and jQuery is "installed". Go nuts :) -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] click event is not working
http://docs.jquery.com/Events/live On Thu, Jan 7, 2010 at 2:01 PM, CreativeMind wrote: > hi, > i'm appending a child div in a parent div. parent div has already > child div's which have classes ws_c1 and plus. > > $('').addClass('ws_c1').addClass('plus').appendTo($ > ('#'+'parentdiv'+counter)); > > but when i try to do this > $(".ws_c1.plus").click(function() {alert('test');}); > It works on other child div's but not on the appended div's. I've also > tried with Id's. > can you plz help me. > > regards, > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] How to unsubscribe from this group?
Oooh... once you're in, well, we can't just let you walk away. O_o On Tue, Jan 5, 2010 at 4:47 PM, Chikkis Corner wrote: > Please unsubscribe me from this group. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Re: How to gain reference to hyperlink that is clicked
On Tue, Jan 5, 2010 at 1:10 PM, Scott Sauyet wrote: > On Jan 5, 3:43 pm, Charlie Griefer wrote: > > Within the function triggered by the click event, $(this) or this are > both > > references to the element that triggered the click. > > More precisely, "this" is a reference the to element. "$(this)" is a > reference to a jQuery wrapper object containing only that element. > Aye. Thanks for the clarification. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] How to gain reference to hyperlink that is clicked
$(document).ready(function() { $('.myButton').click(function() { alert($(this).attr('id')); // alert(this.id) <-- should also work } }); Notice that I added a class="myButton" to each button element, and set the listener for $('.myButton').click(), which listens for a click event on any element that matches that selector. Within the function triggered by the click event, $(this) or this are both references to the element that triggered the click. On Tue, Jan 5, 2010 at 12:35 PM, CoffeeAddict wrote: > > I understand that I can use the .click() method on a hyperlink element. > But > how do I know which element was clicked? First I have to gain reference to > the hyperlink's ID. > > So lets say I have a page of hyperlinks like this in view source: > > ...someurl somebutton > ...someurl somebutton > ...someurl somebutton > ...someurl somebutton > > when a user clicks addButton1, how do I know it's addButton1 that was > referenced so that I can now apply a .click() event on it? > -- > View this message in context: > http://old.nabble.com/How-to-gain-reference-to-hyperlink-that-is-clicked-tp27026713s27240p27026713.html > Sent from the jQuery General Discussion mailing list archive at Nabble.com. > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Re: I would like to get value each time when one of these checkboxes will change status, how can I do that ?
Wow. Never even thought about that, but it makes perfect sense. Thanks for pointing that out :) On Sun, Dec 27, 2009 at 5:52 PM, Ami wrote: > I recommend to use "change" event and not "click" event, becuase users > can change the checkbox without clicking (by using the keyboard). > > On Dec 28, 1:17 am, Charlie Griefer wrote: > > You just want the value of the one that's checked? > > > > $(':checkbox[name=number]').click(function() { > > if ($(this).is(':checked')) alert($(this).val()); > > > > }); > > > > if you want the total of all checked boxes when one is clicked: > > > > $(document).ready(function() { > > $(':checkbox[name=number]').click(function() { > > var total = 0; > > $(':checkbox[name=number]:checked').each(function() { > > total += parseFloat($(this).val()); > > }); > > alert(total); > > }); > > }); > > > > > > On Sun, Dec 27, 2009 at 1:08 PM, dziobacz > wrote: > > > I have: > > > > > > > > > > > > > > > > I would like to get value each time when one of these checkboxes will > > > change status, how can I do that ? For example when first checkbox > > > will be unchecked or second will be checked. Could You help me ? > > > > -- > > Charlie Grieferhttp://charlie.griefer.com/ > > > > I have failed as much as I have succeeded. But I love my life. I love my > > wife. And I wish you my kind of success. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] I would like to get value each time when one of these checkboxes will change status, how can I do that ?
You just want the value of the one that's checked? $(':checkbox[name=number]').click(function() { if ($(this).is(':checked')) alert($(this).val()); }); if you want the total of all checked boxes when one is clicked: $(document).ready(function() { $(':checkbox[name=number]').click(function() { var total = 0; $(':checkbox[name=number]:checked').each(function() { total += parseFloat($(this).val()); }); alert(total); }); }); On Sun, Dec 27, 2009 at 1:08 PM, dziobacz wrote: > I have: > > > > > > I would like to get value each time when one of these checkboxes will > change status, how can I do that ? For example when first checkbox > will be unchecked or second will be checked. Could You help me ? > > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Re: .add()
Sorry, misunderstood. I wasn't clear on what you were trying to do, but saw the "Maybe I'm not understanding the point of .add()", so was trying to clarify that. Glad MorningZ got you sorted :) On Wed, Dec 23, 2009 at 10:59 AM, Scott wrote: > Uh, that's not what I'm asking at all. > > In the documentation example you're passing .add() the "p" selector > which is a string. I want the end result to be the same except instead > of passing a selector string like "p" I want to pass an existing > jquery object. It doesn't seem to work this way and the only time more > elements get added to to jquery object is if you use a selector. > > Sso I want to do more like : > $("div").css("border", "2px solid red") > .add($(this).children()) //see how this line is different >.css("background", "yellow"); > > > On Dec 23, 12:50 pm, Charlie Griefer > wrote: > > As per the docs (http://docs.jquery.com/Traversing/add), > > > > $("div").css("border", "2px solid red") > > .add("p") > > .css("background", "yellow"); > > > > That will add a 2px red border around any 'div' element. > > > > Then add in a new selector and grab all of the elements. Add a > yellow > > background to the previously selected elements, as well as the > newly > > selected elements. > > > > Does that clarify add()? > > > > I'm not sure I understand what it is you're trying to accomplish. Can > you > > explain what you need to do? > > > > > > > > On Wed, Dec 23, 2009 at 10:45 AM, Scott wrote: > > > Maybe I'm not understanding the point of .add() but it doesn't really > > > do what I'd expect nor can I figure out how to do what I thought would > > > be simple. > > > > > I want to combine 2 jquery objects. > > > > > var $obj1 = $(".stuff"); > > > var $obj2 = $(".morestuff"); > > > $obj1.add($obj2); > > > alert($obj1.length); > > > > > This doesn't do anything, it looks like .add() only accepts selection > > > strings which in my example would work but in what I really need to do > > > I have no selection string which would find the specific jquery > > > objects. > > > > -- > > Charlie Grieferhttp://charlie.griefer.com/ > > > > I have failed as much as I have succeeded. But I love my life. I love my > > wife. And I wish you my kind of success. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] .add()
As per the docs (http://docs.jquery.com/Traversing/add), $("div").css("border", "2px solid red") .add("p") .css("background", "yellow"); That will add a 2px red border around any 'div' element. Then add in a new selector and grab all of the elements. Add a yellow background to the previously selected elements, as well as the newly selected elements. Does that clarify add()? I'm not sure I understand what it is you're trying to accomplish. Can you explain what you need to do? On Wed, Dec 23, 2009 at 10:45 AM, Scott wrote: > Maybe I'm not understanding the point of .add() but it doesn't really > do what I'd expect nor can I figure out how to do what I thought would > be simple. > > I want to combine 2 jquery objects. > > var $obj1 = $(".stuff"); > var $obj2 = $(".morestuff"); > $obj1.add($obj2); > alert($obj1.length); > > This doesn't do anything, it looks like .add() only accepts selection > strings which in my example would work but in what I really need to do > I have no selection string which would find the specific jquery > objects. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Sending all checked checkboxes
If I'm understanding you properly... $('input:checkbox.filter:checked') would give you an array of checked checkboxes with class="filter" How you send them via AJAX depends on what the file on the server is expecting. On Wed, Dec 23, 2009 at 9:46 AM, spiraldev wrote: > How would I go about send all of my checked checkboxes with the class > of "filter" via ajax? > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Targeting/selecting via the title atribute of a link?
$('a[title=blog]') On Wed, Dec 23, 2009 at 8:30 AM, Janmansilver wrote: > I have to add som jquery magic to a link where the only unique > identifier is the "title"-atribute? > > my code: > > > > How do I target this via Jquery? > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Latest JQuery File
I'd wager this is an issue with Dreamweaver's parsing of the code. You should -not- be modifying the core jQuery files, unless you really -really- know what you're doing. And if that's the case, you still really should -not- be modifying the core jQuery files. On Tue, Dec 22, 2009 at 11:34 PM, David Matchoulian < davidmatchoul...@gmail.com> wrote: > Dear jQuery Guys, > I downloaded the latest file, and when i opened it in dreamweaver and > scrolled through the code i noticed that half the code is colored > blue, that is half the code is considered "string", i tryed to fix it > myself but i didn't since i was afraid that i might ruin the code. > What is the solution for this problem? > Thank you > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Re: jQuery Selector Help
On Tue, Dec 22, 2009 at 10:40 AM, Charlie Griefer wrote: > On Tue, Dec 22, 2009 at 10:34 AM, Mike Walsh wrote: > >> >> [ ... snipped ... ] >> >> Thanks for pointing me in the right direction. This is what I ended >> up getting to work: >> >>jQuery("span.event", ".calendar-table").each(function(){ >>var html = this.innerHTML.replace(/()\s*\*/ >> g, \'$1\'); >>jQuery(this).html(html) ; >>}) ; >> >> I changed the regular expression slightly to eliminate the .* portion >> and changed .html() to .innerHTML. I don't know enough jQuery to know >> why I had to do that but had seen it elsewhere so tried it and it >> worked. >> >> Thanks, >> >> Mike >> > > .html() retrieves the innerHTML. > > Really no functional difference, but for the sake of consistency, since > you're leveraging jQuery, I'd prefer to see consistent jQuery code (unless > there's a compelling reason not to). > > And yeah... just a preference. Not saying wrong or right. But I am saying > you shouldn't have "-had- to do that" :) > > Anyway, glad you got it working. That's the important bit :) ... and after looking at your code (which always helps), I see you're referencing "this" (as opposed to jQuery's $(this)), which is why html() wouldn't have worked. In that case, sure. It's been said that "this" is more efficient than creating a jQuery reference to it via $(this). So to clarify... this.innerHTML is the functional equivalent of $(this).html(), but without the "cost" of creating a new jQuery object for each iteration of your each(). -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Re: jQuery Selector Help
On Tue, Dec 22, 2009 at 10:34 AM, Mike Walsh wrote: > > [ ... snipped ... ] > > Thanks for pointing me in the right direction. This is what I ended > up getting to work: > >jQuery("span.event", ".calendar-table").each(function(){ >var html = this.innerHTML.replace(/()\s*\*/ > g, \'$1\'); >jQuery(this).html(html) ; >}) ; > > I changed the regular expression slightly to eliminate the .* portion > and changed .html() to .innerHTML. I don't know enough jQuery to know > why I had to do that but had seen it elsewhere so tried it and it > worked. > > Thanks, > > Mike > .html() retrieves the innerHTML. Really no functional difference, but for the sake of consistency, since you're leveraging jQuery, I'd prefer to see consistent jQuery code (unless there's a compelling reason not to). And yeah... just a preference. Not saying wrong or right. But I am saying you shouldn't have "-had- to do that" :) Anyway, glad you got it working. That's the important bit :) -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Re: jQuery Selector Help
2009/12/22 Šime Vidas > Well, you selected BR elements, which are empty elements, so it's no > mystery why this.innerHTML returns undefined... > > Also, DIVs shouldn't appear inside SPANs... > He did state that he's using generated HTML. He has no control over it. Mike - this isn't really a jQuery problem per se. You're jQuery selectors match DOM elements. Not so much the contents of those elements. What you can do is search for the containing element (in this case, you can look for a with a class of "event"), and replace all instances of * with just the . $(document).ready(function() { var newHTML = $('span.event').html().replace(/()\s*\*/g, '$1'); $('span.event').html(newHTML); }); The expression is looking for a (or or ) followed by any white space (including tabs), followed by an asterisk. It replaces that pattern with the alone (removing the asterisk). Disclaimer: I'm no regex guru, so if anyone sees a way to clean up that expression, please feel free. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] simple code not working
couple of debugging steps I'd take: 1) remove the .getJSON() call and just alert('foo'), to ensure that the change event is being triggered as you expect 2) install Firebug in Firefox and check whether or not there are errors in the php document. On Mon, Dec 21, 2009 at 8:16 AM, kikloo wrote: > hi > > i have this simple code: > > $(function() { >$("select#ctlByName").change(function() { > >cid = $(this).val(); >$.getJSON("ajax.php",{cid:cid}, function(json) { >alert("Data Loaded: " + json); >}) >}) > }) > > and its not working. Its set to work when a is changed by > user and it should then get data back from ajax.php which is sending > the data fine. But no alert is coming up and it seems its not working. > > Please help. > > Thanks. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Changing colspan with jQuery
I see where you're changing background colors, but where are you trying to change colspans? untested, but $('myTDelement').attr('colspan', x); ... where 'x' is the numeric value, should work. also, it's criminal to use document.getElementById() within jQuery. $('#element') is so much more elegant :) $(document).ready(function() { $('#plusSign').click(function() { $('.ba_toggle').toggle(); if $('#plusSign').html() == "+") { $('#plusSign').html('-'); $('th.ba_colspan, td.ba_colspan').each(function() { $(this).attr('bgColor','red'); }); } else { $('#plusSign').html('+'); $('th.ba_colspan, td.ba_colspan').each(function() { $(this).attr('bgColor','green'); }); } }); }); On Thu, Dec 17, 2009 at 11:23 AM, davec wrote: > I am trying to change the colspan attribute on some table cells when > the user clicks on a button but it is not affecting the table. Perhaps > someone can tell me what I am doing wrong. Here is my jQuery code: > > < > $(document).ready(function() { > $('#plusSign').click(function(){ > $('.ba_toggle').toggle(); >if(document.getElementById('plusSign').innerHTML=='+') >{ > document.getElementById('plusSign').innerHTML='-'; > $('th.ba_colspan, td.ba_colspan').each(function(){ >$(this).attr('bgColor','red'); > }); >} >else >{ >document.getElementById('plusSign').innerHTML='+'; >$('th.ba_colspan, td.ba_colspan').each(function(){ >$(this).attr('bgColor','green'); >}); >} > }); > }); > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] What is the canonical way of seeing if a selector returns an empty list?
On Thu, Dec 17, 2009 at 7:32 AM, Joe Grossberg wrote: > Instead, I do it like this (since zero is false-y in JavaScript): > > if ( $('.foo').length ) { > alert('at least one matching element'); > } else { > alert('nothing matches'); > } > > But is that the preferred way of doing this? > As far as I am aware, yes... checking the length property is the way that I've seen it done. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] How do I select all elements whose id's begin with ... ?
$('input[id^=DatePref]') On Tue, Dec 15, 2009 at 8:10 AM, laredotorn...@zipmail.com < laredotorn...@zipmail.com> wrote: > Hi, > > I'm using JQuery 1.3. How do I write an expression to select all > elements whose id's begin with "DatePref"? These are all input > type="text" elements if that matters. > > Thanks, - Dave > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] fading
Show us yours, first :) On Thu, Dec 10, 2009 at 6:32 AM, jnf555 wrote: > hi > i am trying to ceate a page where one image fades in over another int > the same position > > can anyone show me the code > thanks > jnf555 > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Problem with assigning events to ajax generated content.
Take a gander at the live() method: http://docs.jquery.com/Events/live On Tue, Dec 8, 2009 at 4:20 PM, Jeff Berry wrote: > I am populating an unordered list with items from an ajax query, after > which I want to attach click events to each list item. Using either load > or $.get I'm able to retrieve the data and post it to the UL correctly. > However, when I then try to immediately retrieve all the list items in that > newly populated UL, I get zero items returned and thus can't attach click > events to them. The UL is not actually being populated until after all of > the scripting runs. If I then rerun the operation I can retreive the items > in the list from the first ajax query, but this is too late because the list > is out of date and does not reflect the new data retrieved from the second > query. So, obviously I don't understand something about the basic order of > operations here. > > > function populateCategories() { > //This loads the categories UL. Once the script runs the items are > listed correctly. > $("#categories").load( > http://localhost/my_account/return_categories.php); > > //But when I try to immediately retreive the list items from that UL > before scripting has run it's course, the items are not available. > //This returns a count of zero items in the list. > var count = $("categories li").size(); > alert(count); > > } > > What can I do to get that list of items and attach click events to them > immediately after the load has returned data and I've populated the UL? Is > there a different way to approach this? The point of this is to be able to > click a button to create a new item, have that written to the database, > update the list of items to reflect the addition, and then attach a click > event to the list items allowing the user to select and edit the items. > > Is there a way to attach events to any list item in the UL without having > to explicitly apply it to each item? > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] unsub
Here's a link. http://groups.google.com/group/jquery-en On Tue, Dec 8, 2009 at 1:26 PM, Lucas Deaver wrote: > I need to unsubscribe from your incessant emails but you put no link in the > email for this. It is common practice since the stone age of emails to do > that, you are very frustrating to work with and I don't like you now. > > PLEASE UNSUBSCRIBE ME!! > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] learn
read http://docs.jquery.com search amazon for jQuery. there are a few books. On Tue, Dec 8, 2009 at 2:24 AM, police wrote: > hi guys, i am interested learn j query, how to learn, can u send any > easy way to learn site? > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] How do I trigger an event when a user presses a key within a text field?
On Sat, Dec 5, 2009 at 1:16 PM, laredotorn...@zipmail.com < laredotorn...@gmail.com> wrote: > Hi, > > What is the event that I trigger if a user enters (or deletes) a > character within a textfield with id = "username"? > > Thanks, - Dave > Bet you can find it in here: http://docs.jquery.com/Events -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Jquery unique ID
http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js</a> "> $(document).ready(function() { $('div.testClass').each(function(i) { $(this).attr('id', 'test' + i) }); }); A B C $('div.testClass').each(function(i) <-- will loop over each instance of a div with the class "testClass". For each iteration of the loop, 'i' is the loop index (e.g. for 1st iteration its value is "1", second iteration, "2", etc). So for each loop, you set the "id" attribute of the div being looped over to "testi" (where "i" represents a number). You'll end up with the first div having an ID of "test1", the second an id of "test2", etc. If you run the code above in Firefox using Firebug, you should be able to see the attributes in the code. On Sat, Dec 5, 2009 at 4:42 AM, kbuntu wrote: > I'm a designer and totally lost when it comes to php or java script. > Perhaps somebody can help me. > > I have several images when hover over it will display a DIV called > testing. The content is dynamically generated by wordpress. My problem > is when I hover over an image it displays all the div's with the class > "testing". What I need to do is somehow generate a random id by > Jquery. > > > >$(document).ready(function() { >var hide = false; >$(".rss-link").hover(function(){ >if (hide) clearTimeout(hide); >$(".testing").fadeIn(); >}, function() { >hide = setTimeout(function() {$(".testing").fadeOut > ("slow");}, 500); >}); >$(".testing").hover(function(){ >if (hide) clearTimeout(hide); >}, function() { >hide = setTimeout(function() {$(".testing").fadeOut > ("slow");}, 500); >}); >}); > > > > this is my dynamic created > content > > Thank you in advance. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Re: Basic Bind Question
Thanks all. I appreciate all the responses and examples. Really helps out a lot. Charlie On Fri, Dec 4, 2009 at 11:34 AM, seasoup wrote: > Got two more uses for ya. Namespacing of events: > > // set two click events with different namespaces > $('.button').bind('click.namespace1', function () { > > }).bind('click.namespace2', function () { > > }); > > //remove just one of them > $('.button').unbind('click.namespace1', function () { > > }); > > and passing of data: > > $('.button').bind('click', {'name': 'value'}, function (e) { > console.log(e.data.name); // logs value > }); > > > > > > On Dec 4, 10:41 am, Rey Bango wrote: > > Yep Karl's explanation was great. Also, you can leverage bind() to work > > with your own custom events in the case where you want to define > > something that needs to be triggered based on another action. Using the > > code from the docs, you can see what I'm talking about: > > > > $("p").bind("myCustomEvent", function(e, myName, myValue){ > >$(this).text(myName + ", hi there!"); > >$("span").stop().css("opacity", 1) > > .text("myName = " + myName) > > .fadeIn(30).fadeOut(1000); > > }); > > $("button").click(function () { > >$("p").trigger("myCustomEvent", [ "John" ]); > > }); > > > > Rey... > > > > Charlie Griefer wrote: > > > Hi Karl: > > > > > Awesome! Got it :) > > > > > Thanks for the explanation and examples. > > > > > Charlie > > > > > On Fri, Dec 4, 2009 at 9:01 AM, Karl Swedberg > > <mailto:k...@englishrules.com>> wrote: > > > > > Hey Charlie, > > > > > methods such as .click() and .mouseover() are just convenience > > > methods. They all use .bind() internally. One nice thing about > > > .bind() is that you can use multiple event types with it. For > > > example, instead of doing this: > > > > > $('a') > > > .mouseover(function() { > > > var $link = $(this); > > > // do something with $link > > > }) > > > .mouseout(function() { > > > var $link = $(this); > > > // do something with $link > > > }); > > > > > You can combine them and avoid some repetition: > > > > > $('a') > > > .bind('mouseover mouseout', function(event) { > > > var $link = $(this); > > > if (event.type == 'mouseover') { > > > // do something with $link on mouseover > > > } else { > > > // do something with $link on mouseout > > > } > > > }); > > > > > --Karl > > > > > > > > Karl Swedberg > > >www.englishrules.com<http://www.englishrules.com> > > >www.learningjquery.com<http://www.learningjquery.com> > > > > > On Dec 4, 2009, at 11:46 AM, Charlie Griefer wrote: > > > > >> Hi All: > > > > >> I've read over the docs, but don't quite understand what the > > >> bind() event provides versus just assigning a particular event > > >> handler to a selected element (or set of elements). > > > > >> For example, consider the code below. What's the difference > > >> between the interaction with the elements of class "first", > > >> and the elements of class "second"? Isn't the second bit > > >> effectively binding a click event handler to a specific batch of > > >> "p" elements just as the first one is? > > > > >> Just not grokking it. Would appreciate if anybody could enlighten > me. > > > > >> > >> src="<a rel="nofollow" href="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js">http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js</a> > "> > > > > >> > > >> $(document).ready(function() { > > >> $('p.first').bind('click', function() { > > >> alert($(this).text()); > > >> }); > > > > >> $('p.second').click(function() { > > >> alert($(this).text()); > > >> }); > > >> }); > > >> > > > > >> A > > >> B > > >> C > > >> D > > >> E > > > > >> > > > > >> F > > >> G > > >> H > > >> I > > >> J > > > > >> -- > > >> Charlie Griefer > > >>http://charlie.griefer.com/ > > > > >> I have failed as much as I have succeeded. But I love my life. I > > >> love my wife. And I wish you my kind of success. > > > > > -- > > > Charlie Griefer > > >http://charlie.griefer.com/ > > > > > I have failed as much as I have succeeded. But I love my life. I love > my > > > wife. And I wish you my kind of success. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Basic Bind Question
Hi Karl: Awesome! Got it :) Thanks for the explanation and examples. Charlie On Fri, Dec 4, 2009 at 9:01 AM, Karl Swedberg wrote: > Hey Charlie, > > methods such as .click() and .mouseover() are just convenience methods. > They all use .bind() internally. One nice thing about .bind() is that you > can use multiple event types with it. For example, instead of doing this: > > $('a') > .mouseover(function() { > var $link = $(this); > // do something with $link > }) > .mouseout(function() { > var $link = $(this); > // do something with $link > }); > > You can combine them and avoid some repetition: > > $('a') > .bind('mouseover mouseout', function(event) { > var $link = $(this); > if (event.type == 'mouseover') { > // do something with $link on mouseover > } else { > // do something with $link on mouseout > } > }); > > --Karl > > > Karl Swedberg > www.englishrules.com > www.learningjquery.com > > > > > On Dec 4, 2009, at 11:46 AM, Charlie Griefer wrote: > > Hi All: > > I've read over the docs, but don't quite understand what the bind() event > provides versus just assigning a particular event handler to a selected > element (or set of elements). > > For example, consider the code below. What's the difference between the > interaction with the elements of class "first", and the elements of > class "second"? Isn't the second bit effectively binding a click event > handler to a specific batch of "p" elements just as the first one is? > > Just not grokking it. Would appreciate if anybody could enlighten me. > > http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js</a> > "> > > > $(document).ready(function() { > $('p.first').bind('click', function() { > alert($(this).text()); > }); > > $('p.second').click(function() { > alert($(this).text()); > }); > }); > > > A > B > C > D > E > > > > F > G > H > I > J > > -- > Charlie Griefer > http://charlie.griefer.com/ > > I have failed as much as I have succeeded. But I love my life. I love my > wife. And I wish you my kind of success. > > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Basic Bind Question
Hi All: I've read over the docs, but don't quite understand what the bind() event provides versus just assigning a particular event handler to a selected element (or set of elements). For example, consider the code below. What's the difference between the interaction with the elements of class "first", and the elements of class "second"? Isn't the second bit effectively binding a click event handler to a specific batch of "p" elements just as the first one is? Just not grokking it. Would appreciate if anybody could enlighten me. http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js</a> "> $(document).ready(function() { $('p.first').bind('click', function() { alert($(this).text()); }); $('p.second').click(function() { alert($(this).text()); }); }); A B C D E F G H I J -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] books to help indoctrinate java developers?
On Tue, Nov 24, 2009 at 7:24 AM, mattkime wrote: > I recently convinced my company to go with jQuery. (yaaay!) and now > i've been tasked with spreading my knowledge around. i was curious if > anyone could recommend books to put in the hands of experienced > programmers who are new to javascript. for the basics, I'd point them > to JavaScript: The Good Parts. what about more advanced js books and > jquery specific books? i've taught myself with online resources but > these people are asking specifically about dead tree resources. > http://www.amazon.com/jQuery-Action-Bear-Bibeault/dp/1933988355/177-2519159-8655561?SubscriptionId=1SDRSQH20CF1ZSXE6Y02 http://www.amazon.com/Learning-jQuery-1-3-Jonathan-Chaffer/dp/1847196705/ref=pd_bxgy_b_text_b http://jqueryenlightenment.com/ -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] What is the opposite of :checked?
http://docs.jquery.com/Selectors/not On Thu, Nov 19, 2009 at 12:55 PM, Atkinson, Sarah < sarah.atkin...@cookmedical.com> wrote: > What is the opposite of :checked? > > Is it :unchecked? Or would you use the not (!) > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Trouble with IE breaking script
This may just be another example of IE sucking. I get an error on IE 6, "unexpected call to method or property access". Googling that error message (and adding 'style' to the search) suggests that manipulating the style attribute dynamically on IE is somewhat... problematic :\ On Thu, Nov 19, 2009 at 11:45 AM, Atkinson, Sarah < sarah.atkin...@cookmedical.com> wrote: > > > Yes In the function that this bit of code resides > > > On 11/19/09 2:43 PM, "Charlie Griefer" wrote: > > leftOffset is a variable you're defining somewhere? > > On Thu, Nov 19, 2009 at 11:39 AM, Atkinson, Sarah < > sarah.atkin...@cookmedical.com> wrote: > > > IE 7 haven’t tried any others. And it doesn’t work it doesn’t text and it > cause another function that hides and shows a div to not work as well. The > only fire bug error I get is "Reload to activate window console" although IE > has a message saying error on page > > > On 11/19/09 2:35 PM, "Charlie Griefer" http://charlie.grie...@gmail.com> > wrote: > > What version of IE? > Define "break"? > > On Thu, Nov 19, 2009 at 11:29 AM, Atkinson, Sarah < > sarah.atkin...@cookmedical.com <http://sarah.atkin...@cookmedical.com> > > wrote: > > I’m having trouble with IE > This code seems to break in IE > > var cssString= "label.error{left:"+leftOffset+"px;}";$('head > style').text(cssString); > > > > > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Trouble with IE breaking script
leftOffset is a variable you're defining somewhere? On Thu, Nov 19, 2009 at 11:39 AM, Atkinson, Sarah < sarah.atkin...@cookmedical.com> wrote: > > IE 7 haven’t tried any others. And it doesn’t work it doesn’t text and it > cause another function that hides and shows a div to not work as well. The > only fire bug error I get is "Reload to activate window console" although IE > has a message saying error on page > > > On 11/19/09 2:35 PM, "Charlie Griefer" wrote: > > What version of IE? > Define "break"? > > On Thu, Nov 19, 2009 at 11:29 AM, Atkinson, Sarah < > sarah.atkin...@cookmedical.com> wrote: > > I’m having trouble with IE > This code seems to break in IE > > var cssString= "label.error{left:"+leftOffset+"px;}";$('head > style').text(cssString); > > > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Trouble with IE breaking script
What version of IE? Define "break"? On Thu, Nov 19, 2009 at 11:29 AM, Atkinson, Sarah < sarah.atkin...@cookmedical.com> wrote: > I’m having trouble with IE > This code seems to break in IE > > var cssString= "label.error{left:"+leftOffset+"px;}";$('head > style').text(cssString); > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] show/hide div on select change
You're missing a $ on this line: ('#id_status').change(function() { Change to: $('#id_status').change(function() { unsolicited word of advice... run firebug :) On Wed, Nov 18, 2009 at 11:44 AM, mtuller wrote: > I am trying to have a div show and hide based on the value of a select > list. I have looked at a number of examples, but can't seem to get it > to work. Would appreciate someone taking a look at what I have and > giving me any advice. > > > $(document).ready(function() { >$('div.textfield1').hide(); > >('#id_status').change(function() { > >if ($("#id_status").val() == 6){ >$('div.textfield1').show(); >} >else{ >$('div.textfield1').hide(); >} > }); > }); > > > Status: > >New >In Review >Working On >Elevated >Approved >Deferred > Denied >Duplicate >Completed >Needs more information > > > > test > > > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] imitate link
On Tue, Nov 17, 2009 at 6:56 PM, runrunforest wrote: > Can make behave as ? > > For exmaple, I have Home, I want to go to homepage when i click > b. > Why would you not just use CSS to style an element to be bold and not underlined? -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] sending a html part to a printer
On Wed, Nov 11, 2009 at 9:54 AM, theUnseen wrote: > Hi guys, is it possible to print a part of the html page using JQuery > and printed copy must not include the browser addons like datetime and > the url. I want the print out to be a plain document with just data > (Ms Word look alike print out) > > Thank you in advance! > AFAIK, the "browser addons" are local user preferences, and I don't think they can be manipulated via code. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Re: JavaScript switched off
Scott's solution, as he mentioned, goes "the other way", but still does what the OP wanted. If the user doesn't have JS enabled, the location.href won't fire, and the current page will still render fine. If the user does have JS enabled, the location.href call will redirect them to the JS-enhanced page. The OP was looking for a W3C compliant solution. AFAIK, Scott's option fits that bill. On Tue, Nov 10, 2009 at 9:20 AM, waseem sabjee wrote: > the op wanted to redirect without javascript > > > On Tue, Nov 10, 2009 at 7:02 PM, Scott Sauyet wrote: > >> On Nov 10, 10:53 am, "factoringcompare.com" >> wrote: >> > What’s the best way to redirect when a users browser has JavaScript >> > switched off? >> >> How about going the other way? >> >>document.location.href="enabled.html"; >> >> Better still when possible is to unobtrusively enhance the non-js page >> with additional functionality. That is generally the cleanest way of >> making sure that your content is accessible, available to search >> engines, and still has all your cool dynamic behavior for those with >> JS on. >> >> -- Scott >> > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Re: How to keep two items having the same value
On Mon, Nov 9, 2009 at 4:06 PM, Dave Methvin wrote: > > > What I want is: When the user choose an item from the number1 > > , the number2 will automatically change to the same > > value to the number2. > > Maybe something like this? > > $("select[name=number1]").change(function(){ > $("select[name=number2]").val( > $(this).val() > ); > }); > > If the change event doesn't do it for you, take a look at .click() > or .blur(). > change() oughtta do it. What you have there should work perfectly. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Div change
On Mon, Nov 9, 2009 at 3:26 PM, factoringcompare.com < firstfacto...@googlemail.com> wrote: > When changes with a AJAX response I would > like to fire a alert. What am I doing wrong? > > $(document).ready(function() { > > $("#MyResult").change(function (){ >alert('hi'); > }); > > }); > I think the change event only applies to and elements. Most AJAX methods let you specify some sort of callback function to execute. See http://docs.jquery.com/Ajax/ajaxComplete#callback or http://docs.jquery.com/Ajax/load#urldatacallback or http://docs.jquery.com/Ajax/jQuery.getJSON#urldatacallback or (well, you get the point). Point being... you should be able to fire your alert as part of the callback function :) -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] jquery form and "myfom"
I want that 10 minutes of my life back... :\ On Mon, Nov 9, 2009 at 2:47 PM, Lord Gustavo Miguel Angel < goosfanc...@gmail.com> wrote: > ok. > thnks´ i treid it. > > > *From:* Charlie Griefer > *Sent:* Monday, November 09, 2009 7:41 PM > *To:* jquery-en@googlegroups.com > *Subject:* Re: [jQuery] jquery form and "myfom" > > name your elements with whatever name you want. > > > > can be selected via: > > $('#xyz') > $('.blah') (this will return an array of -all- elements of class "blah") > $('form') (this will return an array of -all- form elements on the pag) > $('form[name=gustavo]') > $('form[id=xyz]') > $('form[class=blah]') > $('form#xyz') > > Is there a specific question here? > > On Mon, Nov 9, 2009 at 2:33 PM, Lord Gustavo Miguel Angel < > goosfanc...@gmail.com> wrote: > >> then... >> what alternative have? >> thank´s >> >> *From:* Charlie Griefer >> *Sent:* Monday, November 09, 2009 7:18 PM >> *To:* jquery-en@googlegroups.com >> *Subject:* Re: [jQuery] jquery form and "myfom" >> >> On Mon, Nov 9, 2009 at 2:16 PM, Lord Gustavo Miguel Angel < >> goosfanc...@gmail.com> wrote: >> >>> hi, >>> jquery form only work if name of form is "myform"? is correct afirmation? >>> >> >> there are no such restrictions/limitations. >> >> Any page element can have any valid name value (any valid value for any >> attribute, actually). >> >> -- >> Charlie Griefer >> http://charlie.griefer.com/ >> >> I have failed as much as I have succeeded. But I love my life. I love my >> wife. And I wish you my kind of success. >> > > > > -- > Charlie Griefer > http://charlie.griefer.com/ > > I have failed as much as I have succeeded. But I love my life. I love my > wife. And I wish you my kind of success. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] jquery form and "myfom"
name your elements with whatever name you want. can be selected via: $('#xyz') $('.blah') (this will return an array of -all- elements of class "blah") $('form') (this will return an array of -all- form elements on the pag) $('form[name=gustavo]') $('form[id=xyz]') $('form[class=blah]') $('form#xyz') Is there a specific question here? On Mon, Nov 9, 2009 at 2:33 PM, Lord Gustavo Miguel Angel < goosfanc...@gmail.com> wrote: > then... > what alternative have? > thank´s > > *From:* Charlie Griefer > *Sent:* Monday, November 09, 2009 7:18 PM > *To:* jquery-en@googlegroups.com > *Subject:* Re: [jQuery] jquery form and "myfom" > > On Mon, Nov 9, 2009 at 2:16 PM, Lord Gustavo Miguel Angel < > goosfanc...@gmail.com> wrote: > >> hi, >> jquery form only work if name of form is "myform"? is correct afirmation? >> > > there are no such restrictions/limitations. > > Any page element can have any valid name value (any valid value for any > attribute, actually). > > -- > Charlie Griefer > http://charlie.griefer.com/ > > I have failed as much as I have succeeded. But I love my life. I love my > wife. And I wish you my kind of success. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] jquery form and "myfom"
On Mon, Nov 9, 2009 at 2:16 PM, Lord Gustavo Miguel Angel < goosfanc...@gmail.com> wrote: > hi, > jquery form only work if name of form is "myform"? is correct afirmation? > there are no such restrictions/limitations. Any page element can have any valid name value (any valid value for any attribute, actually). -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Confirm Delete
On Mon, Nov 9, 2009 at 8:58 AM, Dave Maharaj :: WidePixels.com < d...@widepixels.com> wrote: > I am attempting to add a class to a div before deleting it. I just cant > get the class to remove if the user selects no. > > Anyone have tips or a link with suggestions? I found the jquery.confirm.js > script but unable to add a class to the element being deleted before confirm > Hard to give guidance without seeing what code you are using now. Also, in your first paragraph you say "I just cant get the class to remove". In your second paragraph, you say you are "unable to add a class". So not sure which it is. Either way, $('#myDiv').addClass('className'); or $('#myDiv').removeClass('className') should be all you need. If those aren't working out, seeing some code would go a long way towards helping to troubleshoot. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Characters in a string
On Sun, Nov 8, 2009 at 10:53 AM, Dave Maharaj :: WidePixels.com < d...@widepixels.com> wrote: > I have a string where i need to get the last specific number of > characters but cant seem to find an answer when you don't know the length of > the strings since its dynamic. > > var str="/folder/subfolder/setfolder/6ab0e34e915"; > > where i need the last 11 digits (6ab0e34e915). The folder names change so > that number is never know to subtrct back from leaving me with 11 > straight JS. var str = "/folder/subfolder/setfolder/6ab0e34e915"; var arr = str.split('/'); // converts your string to an array, delimited by the '/' character var myNumber = arr[arr.length-1]; -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Append Help Issue
Try prepend() instead of prependTo()? http://docs.jquery.com/Manipulation/prepend On Wed, Nov 4, 2009 at 9:40 AM, Dave Maharaj :: WidePixels.com < d...@widepixels.com> wrote: > Ok i changed the code to: > > $('').prependTo('#sortable').fadeIn('slow').html(response); > > My response is already in a which has variables from the php script so > I need it returned in the response. > > So I end up with being added to the sortable list (extra li set i dont > need) > > code. > > > > How can I just insert the response to the #sortable at the top? > > Thanks again, > > Dave > > -- > *From:* Dave Maharaj :: WidePixels.com [mailto:d...@widepixels.com] > *Sent:* November-04-09 1:40 PM > *To:* jquery-en@googlegroups.com > *Subject:* RE: [jQuery] Append Help > > That certainly was fast. > > Thanks, just what i needed. > > Dave > > -- > *From:* Charlie Griefer [mailto:charlie.grie...@gmail.com] > *Sent:* November-04-09 1:35 PM > *To:* jquery-en@googlegroups.com > *Subject:* Re: [jQuery] Append Help > > shot in the dark here... but prependTo()? > > On Wed, Nov 4, 2009 at 9:01 AM, Dave Maharaj :: WidePixels.com < > d...@widepixels.com> wrote: > >> I am uploading images and once uploaded they appear in my sortable list. >> >> I have >> success response: >> >> $('').appendTo('#sortable').fadeIn('slow').html(response); >> >> page code: >> >> image1 -> are there when the page loads >> image2 -> are there when the page loads >> image3 -> are there when the page loads >> >> image4 -> newly added image appears here but I would like it to >> appear above image1 >> >> >> But I would like to have it appear at the top. What I have adds it to the >> very bottom of the list. How can I have it appear at the top of the list? >> >> Thanks >> >> Dave >> > > > > -- > Charlie Griefer > http://charlie.griefer.com/ > > I have failed as much as I have succeeded. But I love my life. I love my > wife. And I wish you my kind of success. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Append Help
shot in the dark here... but prependTo()? On Wed, Nov 4, 2009 at 9:01 AM, Dave Maharaj :: WidePixels.com < d...@widepixels.com> wrote: > I am uploading images and once uploaded they appear in my sortable list. > > I have > success response: > > $('').appendTo('#sortable').fadeIn('slow').html(response); > > page code: > > image1 -> are there when the page loads > image2 -> are there when the page loads > image3 -> are there when the page loads > > image4 -> newly added image appears here but I would like it to > appear above image1 > > > But I would like to have it appear at the top. What I have adds it to the > very bottom of the list. How can I have it appear at the top of the list? > > Thanks > > Dave > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] i can't use HTML ID's appended dynamically
On Mon, Nov 2, 2009 at 12:00 AM, Aymen louati wrote: > Hi Guys i'm having a serious problem : > i'm using a JSON File to bring data and append it into HTML element so > i can get few divs and a link i automatically generate the > ID's then i select each ID and call a jdialog plugin so i can display > a dialog window > the problem is that the jdialog is not working based on generated ID's > but it works when ever i name it statically > i tried to change the position of the script puting in down the page > but still got nothing and yes i got this problem so many times i feel > like i'm having a missing part out the jquery puzzle any information > would be so helpful and appreciated thank you this is a part of the > code > See the jQuery live() method: http://docs.jquery.com/Events/live "*Added in jQuery 1.3:* Binds a handler to an event (like click) for all current - and future - matched element. Can also bind custom events." Note the "and future". Out of the box, jQuery events won't be bound to elements that were added to the DOM after the page has loaded. To do this, you need to use live(). -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery]
On Sat, Oct 31, 2009 at 8:43 AM, hno wrote: > Hi > > I’m novice in jquety. I want to retrieve different properties like src , > height and other from the elements in the page or set the value for them . > can you help me to do this work > Have you read the docs? http://docs.jquery.com Is there a specific piece that you're having trouble with? What have you tried so far and what obstacles are you encountering? -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
Re: [jQuery] Preventing form submit
On Thu, Oct 29, 2009 at 9:21 AM, SamCKayak wrote: > I've added a jQuery .onClick to a form submit. > > Is there a way to prevent the form from submitting? > return false in the click handler. $('#myFormSubmit').click(function() { do stuff; return false; }); Altho, I'm wondering if it'd be better handled (understanding that "better" is subjective) to use the form's submit method rather than the submit button's click method. e.g.: $('#myFormID').submit(function() { do stuff; return false; } I can't elaborate on why, other than I've been told way back in the day that it's "better" to not use an onclick on a submit button, but rather the onsubmit on the form itself. Maybe somebody on the list can elaborate on that... but either way should give you the results that you're looking for. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: JQuery cloned elements new class isn't recognized.
http://docs.jquery.com/Events/live elements added after the initial DOM load will not be recognized by jQuery unless the afore-referenced live() method is used. On Wed, Oct 21, 2009 at 12:40 PM, Ali wrote: > > Hey. I have two functions show after the message. The first works > fine. When a checkbox is clicked with the class availableProfile, its > class is removed, selectedProfile added. It is then appended to > anotehr list and destroyed in the original. However when i click the > now moved checkbox it doesn't recognize it has the new class of > selectedProfile. > >$(".availableProfile").click(function(event) { >elementID = event.target.id; >elementGroup = elementID.split("__"); >$(this).removeClass("availableProfile"); >$(this).addClass("selectedProfile"); >$(this).parent().clone(true).appendTo("#" + > elementGroup[0] + > "_selected"); >$(this).parent().remove(); >}); > > > $(".selectedProfile").click(function(event) { > >elementID = event.target.id; >elementGroup = elementID.split("__"); >$(this).removeClass("selectedProfile"); >$(this).addClass("availableProfile"); > $(this).parent().clone(true).appendTo("#" + > elementGroup[0] + > "_available"); >$(this).parent().remove(); > >}); -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Copy content from one field to another
On Mon, Oct 19, 2009 at 7:28 PM, ReynierPM wrote: > > Isn't working. > > HTML Code: > Same id="same" onclick="doCopy" /> > > First Name: name="first_name" id="first_name" value="" size="" /> > Middle Name: id="first_name1" value="" size="" /> > > JS Code: > function doCopy(){ > $("first_name1").val($("first_name").val()) > } > Where is the error? > Your selectors are incorrect. $('first_name1') looks for a element in the DOM (there is none). You're referencing by ID, so you want to preface the ID with a # sign (similar to CSS). $('#first_name1').val($('#first_name').val()) -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Color based on table data
does this help? http://charlie.griefer.com/blog/index.cfm/2009/8/18/jQuery--Manipulating-Table-Row-Background-Colors (there are 3 parts to the "series"... links to parts 2 and 3 at the bottom of the entry) On Tue, Oct 13, 2009 at 10:31 AM, Chris wrote: > > I have a table of data brought in through lift and in it is a status > column. I am wondering if there is an easy way to color a row based > on the contents of that column. Any status of broken was red, edited > was yellow and finalized was green. It seems like I could write a > widget for doing this, but I don't know how it would work and have > little experience with creating my own widgets.I don't think linking > any of my code would really help the cause, but here is the > initialization which includes functions for mouseover color changes. > > >$(document).ready(function() { > >// Adds "over" class to rows on mouseover >$(".tablesorter tr").mouseover(function(){ >$(this).addClass("rowHover"); >}); > >// Removes "over" class from rows on mouseout >$(".tablesorter tr").mouseout(function(){ >$(this).removeClass("rowHover"); >}); > >$('.tablesorter selectThisRow').click(function() { >$(this).parent('tr').addClass('selected'); > >}); > > >$("#claims").tablesorter( >{ > >sortList:[[4,0],[6,0]], >widgets: ['zebra'], >headers: { >0: { sorter: false }, >1: { sorter: false }, >2: { sorter: false }, >3: { sorter: false }, >5: { sorter: false }, >7: { sorter: false }, >8: { sorter: false } >} >}) >.tablesorterPager({container: $("#pager")}); > }); > > > I'm working with scala and lift as well so I'm bringing in the table > data from a database when the page loads. > > Any advice would be helpful here, whether you think a widget is how to > make the colors adjust, or creating more JS functions for doing it. > > Thanks in advance, > > Chris > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Please say the meaning of $("#username") or $("#newUser").bind("click",{},function(){}) and..........
On Fri, Oct 9, 2009 at 10:30 PM, anjith wrote: > > i am using Jquery and javascript from long back but i don't know what > this really means and what they return etc can any explain theseor > can u just any wesite containing tutorials about these codings. > > > $("#username") > > $("#newUser").bind("click",{},function(){}) > > > $("#spamimage").attr({src:""}) > > I know what functions they do but i am unable to write my own > programing using these , the third command i know it is returning src > for a image but what is syntax and how to call value in a div or p tag > and how to return values in to those tags using these type of coding > can u say any books/websites or any e-material also helpful to me... > Generally we use document.getElementById().value or > document.getElementByName().value > > See my previous response for the answers to the first two, including websites. Search Amazon for jQuery and you'll see a few books. Make sure the books are for jQuery 1.3 (the latest version). The second isn't returning the src for an image. it's setting the src attribute to be an empty string on the image with id="spamimage". $('#foo') is jQuery notation for document.getElementById('foo'). Much more concise. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Please explain $("#username") $("#newUser").bind("click",{},function(){}) and..........
On Fri, Oct 9, 2009 at 10:18 PM, anjith wrote: > > i am using Jquery and javascript from long back but i don't know what > this really means and what they return etc can any explain theseor > can u just any wesite containing tutorials about these codings. Everything you need is in the docs. http://docs.jquery.com Specific to your question: http://docs.jquery.com/Selectors http://docs.jquery.com/Events/bind $('#username') references the element with id="username" $('#newUser').bind('click', ... ) binds a specific function to the click event of the element with id="newUser" The docs really should be the first place you look for questions like this. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Select all class not " keyword_type_A", please help
First off, I'd add a around those elements. If you do that, and give it an id attribute of 'myList', you can do the following: // hide all list items $('#myList li').hide(); // show only class keyword_type_S $('.#myList .keyword_type_S').show(); You can certainly do the same thing without the , but it's not semantically correct, and it'll be a little more efficient to search within a with a specified id than to search the entire document for a specific class name. On Fri, Oct 9, 2009 at 1:49 AM, Tan wrote: > > Hello. > I have a list: > A > > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > tag > > > I create a code jquery show only class="keyword_type_S" > $(document).ready(function() { > $('#A').click(function() { > $('.keyword_type_A').show(); > $('^li.keyword_type_A').hide(); > > // $('div:not('.keyword_type_A')').hide(); > > }); > }); > but it's not work. Please help. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Hide row if empty
On Thu, Oct 8, 2009 at 5:10 PM, Wacko Jacko wrote: > > Hi There. Yeah, just did. Thanks for that! > > Why does my test using the same code not work :( > > http://www.noosabiosphere.org.au/tester.htm > Viewing the source, that isn't empty. it's got whitespace characters (spaces and/or tabs and/or newlines) There should be a few ways you can fix that. If you're generating this content dynamically, you should be able to trim the data on the server side. If not, you can trim it out on the client via a JS regex or jQuery.trim(). if (jQuery.trim($answer.text()) == '') -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Downloading Jquery
On Thu, Oct 1, 2009 at 9:41 AM, tendai wrote: > > Im creating a photo gallery that uses jquery. After downloading jquery > it wont let me run it. Anybody know whats up with that. > You're really going to have to elaborate if you expect any helpful answers (other than this one) :) -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Hide row if empty
Assuming you can turn those id's into classes (where you have id="database")... you can do the following: $(document).ready(function(){ $('ul .database').each(function() { if ($(this).text() == "") { $(this).parent().hide(); } }); }); On Wed, Sep 30, 2009 at 10:14 PM, Charlie Griefer wrote: > If you're working with server side data like that, couldn't you just write > a conditional in whatever language you're using (PHP, CF, ASP, etc) to not > display the if no data? > > Also, do you really mean to re-use "database" as an ID for multiple > elements? ID's ought to be unique. > > > On Wed, Sep 30, 2009 at 9:43 PM, Wacko Jacko wrote: > >> >> Hi All, >> >> If I had a list displaying data as follows: >> >> >> Label Here{content >> here if available from database} >> Label Here{content >> here if available from database} >> >> >> Could I hide the whole if their is nothing >> available to show from the database in ? >> >> Thanks in advance for your help >> >> Jack >> >> > > > -- > Charlie Griefer > http://charlie.griefer.com/ > > I have failed as much as I have succeeded. But I love my life. I love my > wife. And I wish you my kind of success. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Hide row if empty
If you're working with server side data like that, couldn't you just write a conditional in whatever language you're using (PHP, CF, ASP, etc) to not display the if no data? Also, do you really mean to re-use "database" as an ID for multiple elements? ID's ought to be unique. On Wed, Sep 30, 2009 at 9:43 PM, Wacko Jacko wrote: > > Hi All, > > If I had a list displaying data as follows: > > > Label Here{content > here if available from database} > Label Here{content > here if available from database} > > > Could I hide the whole if their is nothing > available to show from the database in ? > > Thanks in advance for your help > > Jack > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: How to link the JQuery
No worries. Send me a NJ pizza. I haven't had good pizza since I left NJ :) On Wed, Sep 30, 2009 at 8:13 PM, Glen_H wrote: > > Thanks again! > > Thanks from Central jersey too! I saw on your site your home grown > Jersey, Good stuff. > > > Take it easy man. > > Glen > > On Sep 30, 11:05 pm, Charlie Griefer > wrote: > > As with including an external .js file, including an external .css file > is > > not functionally different than including it on the page. The included > css > > will affect any applicable element(s) on the page. > > > > When you manipulate an element's CSS with jQuery, you're just > manipulating > > the CSS of that specific element. > > > > In short, no. There's nothing special you need to do. jQuery doesn't > > technically access or touch the .css file. It applies a particular style > to > > an element. Whether that element "knows" that style depends on whether > or > > not the style is defined (either inline via
[jQuery] Re: How to link the JQuery
As with including an external .js file, including an external .css file is not functionally different than including it on the page. The included css will affect any applicable element(s) on the page. When you manipulate an element's CSS with jQuery, you're just manipulating the CSS of that specific element. In short, no. There's nothing special you need to do. jQuery doesn't technically access or touch the .css file. It applies a particular style to an element. Whether that element "knows" that style depends on whether or not the style is defined (either inline via
[jQuery] Re: How to link the JQuery
in your main page... you link to jquery.js: Then you can either write inline javascript under that... $(document).ready(function() { alert("I am ready"); }); ... or you simply link to other external scripts: ...as many times as you need to. There's no functional difference between using an external .js file or putting your JS in the page itself. Arguably, it's easier to maintain if it's well-organized in included files... but functionally no different. Well, there's the advantage of the .js file being cached in the browser in subsequent page requests... but other than that, functionally no different :) Understand that doing is essentially including the .js on that page. The only thing to bear in mind is that the files will load in the order they're specified. So make sure your include to the jQuery file is first. On Wed, Sep 30, 2009 at 6:46 PM, Glen_H wrote: > > I am confused as to how to link an external JQuery file to my web > page. I understand using . My question is regarding > the file I downloaded from Jquery.com. Do I add code to that file and > link it, or do I link that file and then create a new file with > javascript in it and link that as well? > > Do I create a javascript file and somehow link the Jquery file to that > javascript file? > > > I guess I would need a step by step walkthrough on how to set up > Jquery using all external files. > > > thanks in advance guys > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: jQuery plugin that can do the image effects here?
Hi Michael: Would this do? http://www.gruppo4.com/~tobia/cross-slide.shtml On Wed, Sep 30, 2009 at 5:48 AM, Michael Price wrote: > ‘lo all, > > Boss has been asking me if we can replicate the image fader here: > > http://www.gleneagles.com/home.aspx > > > > Note how it pans and slides as well as fading between images – this one is > done in Flash. We often use the Cycle plugin for a fade-between set of > images but is there a plugin to do something like the above, or can the > Cycle plugin be made to do it? > > > > Regards, > > Michael Price > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Strip out all of the commas in numeric text field
Works for me. Bear in mind you're selecting every input on the page by virtue of $('input'). Bear in mind further that on blur for every input, you're telling jquery to remove the commas from the element with id="test" (by virtue of $('#test'). Do you have an element with id="test" ? On Tue, Sep 29, 2009 at 1:53 PM, factoringcompare.com < firstfacto...@googlemail.com> wrote: > > No it doesn’t work. I’ll work it out. > > > $(document).ready(function(){ > >$("input").blur(function () { > $('#test').val($('#test').val().replace(/,/g,'')); >}); > > }); > > > > On Sep 29, 9:42 pm, Charlie Griefer wrote: > > Because it's completely new to you is exactly why you should be reading > the > > docs :) > > > > Does the code below run? > > > > On Tue, Sep 29, 2009 at 1:27 PM, factoringcompare.com < > > > > > > > > > > > > firstfacto...@googlemail.com> wrote: > > > > > Thank you. JQuery is completly new to me. OK how des the belo code > > > look? > > > > > > > > $(document).ready(function(){ > > > > >$("#test'").blur(function () { > > > $('#test').val($('#test').val().replace(/,/g,'')); > > >}); > > > > > }); > > > > > > > > On Sep 29, 9:17 pm, Charlie Griefer wrote: > > > > jQuery is based on "find something -> do something". The "find > > > something" > > > > is largely done with selectors (similar to CSS selectors). > > > > > > you want to find the element with the id="test". that would be > > > $('#test') > > > > > > you want it to do something when that element receives a blur > event... > > > > > > $('#test').blur(); <-- that's the event, but it's not doing anything > yet. > > > > To do something, pass a function to the blur(): > > > > > > $('#test').blur(function() { }); > > > > > > which, when fleshed out a little more, might look like: > > > > > > $('#test').blur(function() { > > > > alert('I just got blurred!'); > > > > > > }); > > > > > > While inside these "inner functions", you have a handle on the > element > > > that > > > > triggered it. It's referred to as $(this). You can also use "plain > ol' > > > > javascript" and use 'this' (no quotes). Depends on what you're doing > > > with > > > > it. > > > > > > $('#test').blur(function() { > > > > alert(this.id); > > > > alert($(this).attr('id')); // they do the same thing > > > > > > }); > > > > > > Most of this (if not all of it) is covered in the docs. > > > > > >http://docs.jquery.com/andhttp://docs.jquery.com/How_jQuery_Works > > > > > > On Tue, Sep 29, 2009 at 1:04 PM, factoringcompare.com < > > > > > > firstfacto...@googlemail.com> wrote: > > > > > > > Thank you. Could you elaborate on the code so that I can track it > > > > > through and understand > > > > > > > On Sep 29, 8:49 pm, Charlie Griefer > wrote: > > > > > > $('#test').blur(function() { > > > > > > $(this).val($(this).val().replace(/,/g,'')); > > > > > > > > }); > > > > > > > > You "call" it by telling jQuery to "listen" for the blur() event > on > > > the > > > > > > element with id="test" (line 1 above). > > > > > > > > Your code was correct, but you can replace the $('input#test') > with > > > > > $(this), > > > > > > since $(this) will be a reference to the element that triggered > the > > > blur. > > > > > > > > On Tue, Sep 29, 2009 at 12:04 PM, factoringcompare.com < > > > > > > > > firstfacto...@googlemail.com> wrote: > > > > > > > > > Hi, > > > > > > > > > New to jQuery. > > > > > > > > > I would like to strip out all of the commas in numeric text > field > > > > > > > called test on blur. New to jQuery. I have had a go at coding > would > > > it > > > > > > > work? > > > > > > > > > $('input#test').val($('input#test').val().replace(/,/g,'')); > > > > > > > > > and ... how do i calll it? > > > > > > > > -- > > > > > > Charlie Grieferhttp://charlie.griefer.com/ > > > > > > > > I have failed as much as I have succeeded. But I love my life. I > love > > > my > > > > > > wife. And I wish you my kind of success. > > > > > > -- > > > > Charlie Grieferhttp://charlie.griefer.com/ > > > > > > I have failed as much as I have succeeded. But I love my life. I love > my > > > > wife. And I wish you my kind of success.- Hide quoted text - > > > > > > - Show quoted text - > > > > -- > > Charlie Grieferhttp://charlie.griefer.com/ > > > > I have failed as much as I have succeeded. But I love my life. I love my > > wife. And I wish you my kind of success.- Hide quoted text - > > > > - Show quoted text - > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Strip out all of the commas in numeric text field
Because it's completely new to you is exactly why you should be reading the docs :) Does the code below run? On Tue, Sep 29, 2009 at 1:27 PM, factoringcompare.com < firstfacto...@googlemail.com> wrote: > > Thank you. JQuery is completly new to me. OK how des the belo code > look? > > > > $(document).ready(function(){ > >$("#test'").blur(function () { > $('#test').val($('#test').val().replace(/,/g,'')); >}); > > }); > > > > On Sep 29, 9:17 pm, Charlie Griefer wrote: > > jQuery is based on "find something -> do something". The "find > something" > > is largely done with selectors (similar to CSS selectors). > > > > you want to find the element with the id="test". that would be > $('#test') > > > > you want it to do something when that element receives a blur event... > > > > $('#test').blur(); <-- that's the event, but it's not doing anything yet. > > To do something, pass a function to the blur(): > > > > $('#test').blur(function() { }); > > > > which, when fleshed out a little more, might look like: > > > > $('#test').blur(function() { > > alert('I just got blurred!'); > > > > }); > > > > While inside these "inner functions", you have a handle on the element > that > > triggered it. It's referred to as $(this). You can also use "plain ol' > > javascript" and use 'this' (no quotes). Depends on what you're doing > with > > it. > > > > $('#test').blur(function() { > > alert(this.id); > > alert($(this).attr('id')); // they do the same thing > > > > }); > > > > Most of this (if not all of it) is covered in the docs. > > > > http://docs.jquery.com/andhttp://docs.jquery.com/How_jQuery_Works > > > > On Tue, Sep 29, 2009 at 1:04 PM, factoringcompare.com < > > > > > > > > > > > > firstfacto...@googlemail.com> wrote: > > > > > Thank you. Could you elaborate on the code so that I can track it > > > through and understand > > > > > On Sep 29, 8:49 pm, Charlie Griefer wrote: > > > > $('#test').blur(function() { > > > > $(this).val($(this).val().replace(/,/g,'')); > > > > > > }); > > > > > > You "call" it by telling jQuery to "listen" for the blur() event on > the > > > > element with id="test" (line 1 above). > > > > > > Your code was correct, but you can replace the $('input#test') with > > > $(this), > > > > since $(this) will be a reference to the element that triggered the > blur. > > > > > > On Tue, Sep 29, 2009 at 12:04 PM, factoringcompare.com < > > > > > > firstfacto...@googlemail.com> wrote: > > > > > > > Hi, > > > > > > > New to jQuery. > > > > > > > I would like to strip out all of the commas in numeric text field > > > > > called test on blur. New to jQuery. I have had a go at coding would > it > > > > > work? > > > > > > > $('input#test').val($('input#test').val().replace(/,/g,'')); > > > > > > > and ... how do i calll it? > > > > > > -- > > > > Charlie Grieferhttp://charlie.griefer.com/ > > > > > > I have failed as much as I have succeeded. But I love my life. I love > my > > > > wife. And I wish you my kind of success. > > > > -- > > Charlie Grieferhttp://charlie.griefer.com/ > > > > I have failed as much as I have succeeded. But I love my life. I love my > > wife. And I wish you my kind of success.- Hide quoted text - > > > > - Show quoted text - -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Strip out all of the commas in numeric text field
jQuery is based on "find something -> do something". The "find something" is largely done with selectors (similar to CSS selectors). you want to find the element with the id="test". that would be $('#test') you want it to do something when that element receives a blur event... $('#test').blur(); <-- that's the event, but it's not doing anything yet. To do something, pass a function to the blur(): $('#test').blur(function() { }); which, when fleshed out a little more, might look like: $('#test').blur(function() { alert('I just got blurred!'); }); While inside these "inner functions", you have a handle on the element that triggered it. It's referred to as $(this). You can also use "plain ol' javascript" and use 'this' (no quotes). Depends on what you're doing with it. $('#test').blur(function() { alert(this.id); alert($(this).attr('id')); // they do the same thing }); Most of this (if not all of it) is covered in the docs. http://docs.jquery.com/ and http://docs.jquery.com/How_jQuery_Works On Tue, Sep 29, 2009 at 1:04 PM, factoringcompare.com < firstfacto...@googlemail.com> wrote: > > Thank you. Could you elaborate on the code so that I can track it > through and understand > > On Sep 29, 8:49 pm, Charlie Griefer wrote: > > $('#test').blur(function() { > > $(this).val($(this).val().replace(/,/g,'')); > > > > }); > > > > You "call" it by telling jQuery to "listen" for the blur() event on the > > element with id="test" (line 1 above). > > > > Your code was correct, but you can replace the $('input#test') with > $(this), > > since $(this) will be a reference to the element that triggered the blur. > > > > On Tue, Sep 29, 2009 at 12:04 PM, factoringcompare.com < > > > > firstfacto...@googlemail.com> wrote: > > > > > Hi, > > > > > New to jQuery. > > > > > I would like to strip out all of the commas in numeric text field > > > called test on blur. New to jQuery. I have had a go at coding would it > > > work? > > > > > $('input#test').val($('input#test').val().replace(/,/g,'')); > > > > > and ... how do i calll it? > > > > -- > > Charlie Grieferhttp://charlie.griefer.com/ > > > > I have failed as much as I have succeeded. But I love my life. I love my > > wife. And I wish you my kind of success. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Strip out all of the commas in numeric text field
$('#test').blur(function() { $(this).val($(this).val().replace(/,/g,'')); }); You "call" it by telling jQuery to "listen" for the blur() event on the element with id="test" (line 1 above). Your code was correct, but you can replace the $('input#test') with $(this), since $(this) will be a reference to the element that triggered the blur. On Tue, Sep 29, 2009 at 12:04 PM, factoringcompare.com < firstfacto...@googlemail.com> wrote: > > Hi, > > New to jQuery. > > I would like to strip out all of the commas in numeric text field > called test on blur. New to jQuery. I have had a go at coding would it > work? > > > $('input#test').val($('input#test').val().replace(/,/g,'')); > > > and ... how do i calll it? -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Using variables in an Attribute filter
$('p[id=' + myClr + ']').addClass('bold'); you need to concatenate the variable in with the literal text so it can be evaluated. On Tue, Sep 29, 2009 at 10:59 AM, roi wrote: > > I am trying to do something that seems very simple, but can not get to > work! Basically, I want to find an element whose ID equals a certain > value, as represented by a variable. The variable is derived from a > dropdown list. Here is my code: > > $(document).ready(function(){ > $("select").change(function() { > var myClr = $("select").val(); > > $("p[id=myClr]").addClass("bold"); //this is the line giving me > trouble > }); > }); > > I am wondering if it is legal to use a variable within the filter - if > I replace it with an actual ID value it works fine, but when I > substitute the variable name nothing happens. > > I am sure I am doing something dumb! Thanks for any suggestions. > > Roi > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Checking/unchecking parent checkbox
try: $(this).siblings('input[type=checkbox]').attr('checked',''); $(this).siblings('input[type=checkbox]').attr('checked','checked'); On Tue, Sep 29, 2009 at 6:09 AM, evanbu...@gmail.com wrote: > > Anyone? I've been working on this for hours and can't come up with a > solution. Thanks > > On Sep 28, 3:13 pm, "evanbu...@gmail.com" wrote: > > I thought this would do it but no luck > > > > $(this).parents("checkbox:first").attr('checked', false); > > > > On Sep 28, 2:42 pm, "evanbu...@gmail.com" wrote: > > > > > > > > > Hi > > > > > I've been using jQuery a couple of months and I'm really having a > > > blast with it but need a little help with this problem. > > > > > I have a table of records generated from a database that looks like > > > this. Each record has a checkbox with a unique id followed by a > > > person's name and employment status. > > > > > > > >> > class="chkDirector" checked="checked" value="25094" /> > > > J. Pedro > > id="rptDirectors_ctl19_lblDirLName">Reinhard ( > > id="rptDirectors_ctl19_lblRelStatus" class="RelStatus">Retired) > > > > > > > > > > >> > class="chkDirector" checked="checked" value="29632" /> > > > James B. > > id="rptDirectors_ctl23_lblDirLName">Williams ( > > id="rptDirectors_ctl23_lblRelStatus" class="RelStatus">Active > > span>) > > > > > > > > When this checkbox (chkIncludeRetired) is checked/unchecked, the > > > person's employment status (RelStatus) is checked and the entire row > > > is hidden/shown. My jquery code below does this perfectly with no > > > problems. However, in addition to hiding/showing the row. However, I > > > also need the parent checkbox to be checked or unchecked. So if > > > RelStatus == "Retired" then it's parent checkbox also needs to be > > > unchecked else then it's parent checkbox needs to be checked. > > > > > Exclude Retired > > > Directors and Executives > > > > > > > > $(document).ready(function() { > > > $('#chkIncludeRetired').click( > > > function() { > > > $('.RelStatus').each(function() { > > > if ($("#chkIncludeRetired").is(":checked")) > > > { > > > if ($(this).text() == "Retired") > > > $(this).parent().css('display', > > > 'none'); > > > } > > > else > > > { > > > $(this).parent().css('display', > > > 'block'); > > > } > > > }); > > > });}); > > > > > > > > > > Thank you very much.- Hide quoted text - > > > > - Show quoted text - -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Apply CSS to dynamic content after it loads
you can chain on an .addClass('myClassName') ? On Mon, Sep 28, 2009 at 3:09 PM, Sloan Thrasher wrote: > Hi! > > I've got a page that loads dynamic content, sometimes including links. The > CSS seems to apply to the loaded CSS, except for a rule that adds an > "offsite" icon to the end of the link. > I've used Firefind to verify the css selector in the css, and it applies to > the correct elements, but the icon doesn't show up. > Is there anything I need to do after loading the dynamic content to apply > the css? > > Sloan > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: How to handle dynamic clicks?
Incidentally... not sure why you'd need to use split() for your needs there? Could you post some code or explain what your requirement is? You may be going about it the long way (or I may be misunderstanding what you're trying to do) :) On Mon, Sep 28, 2009 at 12:42 PM, Charlie Griefer wrote: > Hi Lionel: > > I've not bought a JavaScript book in ages. But the one that I learned from > a while back is the JavaScript Bible by Danny Goodman. A quick Amazon > search shows that a 7th Edition is in pre-release status (glad to hear) :) > > If you want a jQuery book, there are a couple of ways to go. There's > "jQuery in Action" published by Manning. "Learning jQuery 1.3" by Packt has > some big jQuery names as authors. A new pdf book was just released (you can > also pay extra for a bound copy) at http://jqueryenlightenment.com/. I > bought that last week but haven't had a chance to get to it yet. > > > On Mon, Sep 28, 2009 at 12:34 PM, lionel28 wrote: > >> >> >> Charlie, >> >> Thank you very much. >> I was able to do a split so I get actual value from your code and all is >> fine. >> >> I do whatever I want with php, but could you recommend a book for >> Javascript. >> >> Example: for the split I had to do a Google search :thinking: >> >> A book with all those easy code like yours, like the split would be great. >> >> Thanks again. >> >> Charlie Griefer wrote: >> > >> > You shouldn't need to use a named function, or an inline onclick. >> > >> > If you can move that id attribute into the tag itself, you could do: >> > >> > # ... >> > >> > and then your jQuery would be: >> > >> > $(document).ready(function() { >> > $('a[id^=doedit_]').click(function() { >> > alert(this.id); <-- shows that you have a handle on the >> > specific >> > element that triggered the click >> > return false; >> > }); >> > }) >> > >> > >> > On Mon, Sep 28, 2009 at 4:34 AM, lionel28 >> wrote: >> > >> >> >> >> >> >> Hi, >> >> >> >> I am trying to get the correct div from a form >> >> >> >> I did (I intentionally left the brackets open so it displays here) >> >> span id="doedit_$comment[commentid]"> a onclick= "return >> >> getCommentID($comment[commentid]) >> >> >> >> and for the jQuery >> >> >> >> $(document).ready(function() { >> >> >> >> function getCommentID(cid) >> >> { >> >> >> >> $("#doedit_" + cid).click(function() { >> >> >> >> $("div#newcomment").slideUp("slow"); >> >> $("div#editcomment_" + cid).slideDown("slow"); >> >> >> >> } >> >> }); >> >> >> >> >> >> But nothing is happening. >> >> >> >> Please what is the proper syntax? >> >> >> >> Thank you >> >> -- >> >> View this message in context: >> >> >> http://www.nabble.com/How-to-handle-dynamic-clicks--tp25644199s27240p25644199.html >> >> Sent from the jQuery General Discussion mailing list archive at >> >> Nabble.com. >> >> >> >> >> > >> > >> > -- >> > Charlie Griefer >> > http://charlie.griefer.com/ >> > >> > I have failed as much as I have succeeded. But I love my life. I love my >> > wife. And I wish you my kind of success. >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/How-to-handle-dynamic-clicks--tp25644199s27240p25651479.html >> Sent from the jQuery General Discussion mailing list archive at >> Nabble.com. >> >> > > > -- > Charlie Griefer > http://charlie.griefer.com/ > > I have failed as much as I have succeeded. But I love my life. I love my > wife. And I wish you my kind of success. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: How to handle dynamic clicks?
Hi Lionel: I've not bought a JavaScript book in ages. But the one that I learned from a while back is the JavaScript Bible by Danny Goodman. A quick Amazon search shows that a 7th Edition is in pre-release status (glad to hear) :) If you want a jQuery book, there are a couple of ways to go. There's "jQuery in Action" published by Manning. "Learning jQuery 1.3" by Packt has some big jQuery names as authors. A new pdf book was just released (you can also pay extra for a bound copy) at http://jqueryenlightenment.com/. I bought that last week but haven't had a chance to get to it yet. On Mon, Sep 28, 2009 at 12:34 PM, lionel28 wrote: > > > Charlie, > > Thank you very much. > I was able to do a split so I get actual value from your code and all is > fine. > > I do whatever I want with php, but could you recommend a book for > Javascript. > > Example: for the split I had to do a Google search :thinking: > > A book with all those easy code like yours, like the split would be great. > > Thanks again. > > Charlie Griefer wrote: > > > > You shouldn't need to use a named function, or an inline onclick. > > > > If you can move that id attribute into the tag itself, you could do: > > > > # ... > > > > and then your jQuery would be: > > > > $(document).ready(function() { > > $('a[id^=doedit_]').click(function() { > > alert(this.id); <-- shows that you have a handle on the > > specific > > element that triggered the click > > return false; > > }); > > }) > > > > > > On Mon, Sep 28, 2009 at 4:34 AM, lionel28 > wrote: > > > >> > >> > >> Hi, > >> > >> I am trying to get the correct div from a form > >> > >> I did (I intentionally left the brackets open so it displays here) > >> span id="doedit_$comment[commentid]"> a onclick= "return > >> getCommentID($comment[commentid]) > >> > >> and for the jQuery > >> > >> $(document).ready(function() { > >> > >> function getCommentID(cid) > >> { > >> > >> $("#doedit_" + cid).click(function() { > >> > >> $("div#newcomment").slideUp("slow"); > >> $("div#editcomment_" + cid).slideDown("slow"); > >> > >> } > >> }); > >> > >> > >> But nothing is happening. > >> > >> Please what is the proper syntax? > >> > >> Thank you > >> -- > >> View this message in context: > >> > http://www.nabble.com/How-to-handle-dynamic-clicks--tp25644199s27240p25644199.html > >> Sent from the jQuery General Discussion mailing list archive at > >> Nabble.com. > >> > >> > > > > > > -- > > Charlie Griefer > > http://charlie.griefer.com/ > > > > I have failed as much as I have succeeded. But I love my life. I love my > > wife. And I wish you my kind of success. > > > > > > -- > View this message in context: > http://www.nabble.com/How-to-handle-dynamic-clicks--tp25644199s27240p25651479.html > Sent from the jQuery General Discussion mailing list archive at Nabble.com. > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: How to handle dynamic clicks?
You shouldn't need to use a named function, or an inline onclick. If you can move that id attribute into the tag itself, you could do: ... and then your jQuery would be: $(document).ready(function() { $('a[id^=doedit_]').click(function() { alert(this.id); <-- shows that you have a handle on the specific element that triggered the click return false; }); }) On Mon, Sep 28, 2009 at 4:34 AM, lionel28 wrote: > > > Hi, > > I am trying to get the correct div from a form > > I did (I intentionally left the brackets open so it displays here) > span id="doedit_$comment[commentid]"> a onclick= "return > getCommentID($comment[commentid]) > > and for the jQuery > > $(document).ready(function() { > > function getCommentID(cid) > { > > $("#doedit_" + cid).click(function() { > > $("div#newcomment").slideUp("slow"); > $("div#editcomment_" + cid).slideDown("slow"); > > } > }); > > > But nothing is happening. > > Please what is the proper syntax? > > Thank you > -- > View this message in context: > http://www.nabble.com/How-to-handle-dynamic-clicks--tp25644199s27240p25644199.html > Sent from the jQuery General Discussion mailing list archive at Nabble.com. > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Every post I make, I get an mail error.
Karl - This was happening to me a few weeks ago (from a different @localhost address). Rey took care of it. He may have taken care of this one as well. On Sun, Sep 27, 2009 at 5:51 PM, Karl Swedberg wrote: > Hmmm. I just searched through all jquery-en members and couldn't find > r...@localhost listed. Maybe one of the other admins already deleted it? > > --Karl > > > Karl Swedberg > www.englishrules.com > www.learningjquery.com > > > > > On Sep 26, 2009, at 4:38 PM, Scott Haneda wrote: > > > I believe what happens, is there is a bad address in the group, so when you > post a message to the list, it is sent out to all subscribers. > > Final-Recipient: rfc822; r...@localhost > Original-Recipient: rfc822;r...@localhost > Action: failed > Status: 5.3.0 > > If an email is sent from the group to r...@localhost, it will bounce, and > I am guessing it is bouncing back to the group. Some people are getting > this backscatter, and others are not. If I were to look at my server logs, > I would bet I see it, but I have my server set to block messages that are > backscatter, or have bogus recipients and destinations. > > The list admin needs to find r...@localhost I believe, that would solve > it, though I think the issue is technically deeper than that quick fix. > > -- > Scott * If you contact me off list replace talklists@ with scott@ * > > On Sep 26, 2009, at 8:10 AM, Charlie wrote: > > I posted this issue into Google Groups help forum yesterday, only response > so far "group won't recognize your email address" which is not true > > > Will see what happens > > > Bertilo Wennergren wrote: > > > > evo wrote: > > > Everytime I post to this group through thunderbird, I get a > > undelivered mail message sent back, everytime. > > This has only started happening recently and I can't find any info > > about it anywhere. > > > Just want to know if this is happening to anyone else (as it's only > > when I post to this group) > > > I get those too. > > > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Elements with similar names
$('input[name^=tx_qtde]') See "Attribute Filters" at http://docs.jquery.com/Selectors On Fri, Sep 25, 2009 at 7:12 PM, Carlos Santos wrote: > > I have in one form, many, many text fields with similar names such > as: > > tx_qtde1 > tx_qtde2 > tx_qtde3 > > how i can select all this text fields without using a class, something > like: > > $("tx_qtde * ") > > where the * is the numbers. > > Thanks for your time. > Carlos Santos -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: getJSON callback not firing?
Z: thanks for the response. I'm making my initial foray into using jQuery for AJAX (up 'til now, had only used it for page manipulations). Given your response... would there ever be a situation where .getJSON() would be preferable to .ajax()? It seems odd that jQuery would have 2 methods that essentially do the same thing. Especially if one is near impossible to debug. Thanks, Charlie On Fri, Sep 25, 2009 at 11:58 AM, MorningZ wrote: > > I'd suggest using the more generic $.ajax method so you can actually > catch the error, as the $.getJSON fails silently, which is no good for > programmers :-( > > $.ajax({ > type: GET, > url: "your URL", > processData = true, > data: {}, > dataType: "json", > success: function(json) { > alert("success"); > }, > error: function(x,y,z) { > // x.responseText should have what's wrong > } > }); > > On Sep 25, 2:06 pm, Charlie Griefer wrote: > > Hey all: > > > > I've read the docs and googled the heck out of this, but not seeing what > the > > problem is. > > > > I'm trying to get some data from the server via the getJSON() method. I > do > > see a response in firebug and I've validated the response data at > > JSONLint.com. However, the callback function simply will not fire. I've > > tried to simplify things as much as possible. The CFC returning the data > is > > in the same directory as the calling page. The callback function, for > now, > > should only alert a simple text string (which has evolved from "hi" to > "foo" > > to a censored version below as the hours have passed). > > > > $(document).ready(function() { > > $('a.players').click(function() { > > $.getJSON( > > > > > 'data.cfc?method=getPlayerByID&returnformat=JSON&queryformat=column&playerID=' > > + this.id, > > function(data) { > > alert('i %!%##%* hate you'); > > }); > > return false; > > }); > > > > }); > > > > Here's the response I receive: > > > > > {"ROWCOUNT":1,"COLUMNS":["PLAYERID","PLAYERNAME","PLAYERNUMBER","PLAYERPOSITION","PLAYERIMG","PLAYERCOLLEGE"],"DATA":{"PlayerID":[1],"PlayerName":["Barden, > > > Ramses"],"PlayerNumber":[13],"PlayerPosition":["WR"],"PlayerImg":["http:\/\/ > > assets.giants.com > \/uploads\/players\/2FE2D3BDF4FB443D949D1D39B69ADC03.gif"],"PlayerCollege":["Cal > > Poly"]}} > > > > ...which when pasted into JSONLint returns valid. > > > > If anyone has any ideas, or if there's any additional information that I > can > > provide, I'm all ears. > > > > Thanks! > > Charlie > > > > -- > > Charlie Grieferhttp://charlie.griefer.com/ > > > > I have failed as much as I have succeeded. But I love my life. I love my > > wife. And I wish you my kind of success. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] getJSON callback not firing?
Hey all: I've read the docs and googled the heck out of this, but not seeing what the problem is. I'm trying to get some data from the server via the getJSON() method. I do see a response in firebug and I've validated the response data at JSONLint.com. However, the callback function simply will not fire. I've tried to simplify things as much as possible. The CFC returning the data is in the same directory as the calling page. The callback function, for now, should only alert a simple text string (which has evolved from "hi" to "foo" to a censored version below as the hours have passed). $(document).ready(function() { $('a.players').click(function() { $.getJSON( 'data.cfc?method=getPlayerByID&returnformat=JSON&queryformat=column&playerID=' + this.id, function(data) { alert('i %!%##%* hate you'); }); return false; }); }); Here's the response I receive: {"ROWCOUNT":1,"COLUMNS":["PLAYERID","PLAYERNAME","PLAYERNUMBER","PLAYERPOSITION","PLAYERIMG","PLAYERCOLLEGE"],"DATA":{"PlayerID":[1],"PlayerName":["Barden, Ramses"],"PlayerNumber":[13],"PlayerPosition":["WR"],"PlayerImg":["http:\/\/ assets.giants.com\/uploads\/players\/2FE2D3BDF4FB443D949D1D39B69ADC03.gif"],"PlayerCollege":["Cal Poly"]}} ...which when pasted into JSONLint returns valid. If anyone has any ideas, or if there's any additional information that I can provide, I'm all ears. Thanks! Charlie -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Add content
On Thu, Sep 24, 2009 at 2:03 PM, a1anm wrote: > > Hi, > > I have an unordered list and I would like to use Jquery to add some > 's to it. > > How do I do this? > > Thanks! http://docs.jquery.com/Manipulation/append -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Multiple Links, Find which one was clicked?
Ah, yeah. I should have checked to see if you were on 1.3. Assuming you can move up to 1.3, you can use the live() method (now built-in). I think you'd be able to get by changing your first line to: $('#pending').live('click', function({ > > On Thu, Sep 24, 2009 at 12:05 PM, Steven wrote: > > I was running on 1.2 for some reason. :( Anyway, it works perfectly on > static pages, but when I load the table in via Ajax none of the links > are bound. I'm doing: >// Click events to load requests >$('#pending').click(function(){ >$('#list').hide(600).load('list.php',{type: > 'pending'}).show(600); > $('#description').html(pending); >}); > To load the tables. > > On Sep 24, 12:59 pm, Charlie Griefer > wrote: > > Steven: > > > > It seems to be working here (quick sample thrown together): > > > > http://charlie.griefer.com/getRowID.html > > > > ? > > > > > > > > On Thu, Sep 24, 2009 at 11:55 AM, Steven wrote: > > > > > I cannot seem to get that to work, although it does make sense. I'm > > > using Ajax to load the tables in; I don't know if that is the cause. I > > > did try it on a static page and it still did nothing though. > > > > > On Sep 24, 12:36 pm, Charlie Griefer > > > wrote: > > > > $('a.accept').click(function() { > > > > alert($(this).closest('tr').attr('id')); > > > > > > -- > > > > Charlie Grieferhttp://charlie.griefer.com/ > > > > > > I have failed as much as I have succeeded. But I love my life. I love > my > > > > wife. And I wish you my kind of success. > > > > -- > > Charlie Grieferhttp://charlie.griefer.com/ > > > > I have failed as much as I have succeeded. But I love my life. I love my > > wife. And I wish you my kind of success. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Multiple Links, Find which one was clicked?
Steven: It seems to be working here (quick sample thrown together): http://charlie.griefer.com/getRowID.html ? On Thu, Sep 24, 2009 at 11:55 AM, Steven wrote: > > I cannot seem to get that to work, although it does make sense. I'm > using Ajax to load the tables in; I don't know if that is the cause. I > did try it on a static page and it still did nothing though. > > On Sep 24, 12:36 pm, Charlie Griefer > wrote: > > $('a.accept').click(function() { > > alert($(this).closest('tr').attr('id')); > > > > -- > > Charlie Grieferhttp://charlie.griefer.com/ > > > > I have failed as much as I have succeeded. But I love my life. I love my > > wife. And I wish you my kind of success. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Multiple Links, Find which one was clicked?
$('a.accept').click(function() { alert($(this).closest('tr').attr('id')); }); On Thu, Sep 24, 2009 at 11:22 AM, Steven wrote: > > I have a table that looks something like this: > > > Name > E-Mail > Accept - class="deny">Deny > > > With multiple rows. Each row has a unique ID (numerical). I need to be > able to click on an a.accept, find WHICH one was clicked (which row it > is in), and get the ID of that row. I've been looking around and I > found parent(), but I'm not sure how I can specifically get which > accept link was clicked. > > Can anyone help? -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Way to "convert" DOM event to jQuery event?
On Tue, Sep 22, 2009 at 4:41 PM, WalterGR wrote: > > On Sep 22, 4:35 pm, Ricardo wrote: > > > This doesn't make any sense. If you're already using jQuery why keep > > your handler in the HTML? > > Because I need to pass additional information to the event handler in > a clean way. (i.e. rather than hacks using various attributes on the > anchor.) Is there a non-hackish way to do this? > Hi Walter: Sort of along the lines of what Scott had suggested, but rather than using a plugin, could you use jQuery's built in data() method? http://docs.jquery.com/Core/data#namevalue Assuming you're generating these links dynamically you could assign the 'foobarbaz' value to an element with a particular ID. $(document).ready(function() { $('#myID').data('myFirstArg', 'foobarbaz'); $('#myID').click(function() { alert($(this).data('myFirstArg')); return false; }); }); show details That's a fairly simplistic example. The example in the docs shows how you can store complex data using JSON. Would something like that work? Charlie -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: How to get mouseover and mouseout action to take place after changing div with jquery post method
On Thu, Sep 17, 2009 at 9:02 AM, Ben wrote: > > My question is if i used jquery post method to change some div > content, than this new div won't have mouseover and mouseout affect > anymore, is there anyway to achieve it. Is that needed to trigger > ready function again? > Have a look at the live() method: http://docs.jquery.com/Events/live Another question is can anyone teach me how to add click and dblclick > event to the same div, because if i add both of them then it won't > trigger dblckick event.Thanks a lot. :-) > Dunno this one, but would be interested in hearing if it can be done (and how) :) -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Simple CSS selector Question
Hi Karl: That clears it up completely. Thanks! Charlie On Thu, Sep 17, 2009 at 10:43 AM, Karl Swedberg wrote: > Hey Charlie, > It all comes down to the way the string is parsed. The Sizzle selector > engine uses a Regular Expression to detect whether an attribute selector is > being used: > > ATTR: > /\[\s*((?:[\w\u00c0-\u_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, > > The parts of the regex that deal with quotation marks around the attribute > value are (['"]*) and \3. The part that actually captures the attribute > value is (.*?) > So, it allows for single, double, or no quotation marks around the > attribute value in the selector. > > Come to think of it, it also allows for multiple quotation marks. Strange, > but this would work, too: > $("input[name='''newsletter''']") > > It isn't really related to literal text vs. variable value. In order to > pass in a variable, you need to concatenate it: > > var foo = 'newsletter'; > $("input[name=" + foo + "]") > > Hope that helps explain. > > --Karl > > > Karl Swedberg > www.englishrules.com > www.learningjquery.com > > > > > On Sep 17, 2009, at 12:22 PM, Charlie Griefer wrote: > > Hi Karl: > > Hate to hijack the thread, but hopefully it's somewhat relevant to the > original post. > > When I suggested the single quotes around the value 'bar', I was going off > of what I saw in the docs at > http://docs.jquery.com/Selectors/attributeEquals#attributevalue > > And the code sample: > $("input[name='newsletter']").next().text(" is newsletter"); > > I still consider myself relatively new to jQuery, so could you clarify > about quoting the attribute value? Is it similar to terminating a line with > a semi-colon (e.g. optional in JS)? Or is it literal text vs variable value > (assuming -bar- here is a variable)? > > Thanks! > Charlie > > On Thu, Sep 17, 2009 at 9:06 AM, Karl Swedberg wrote: > >> >> On Sep 17, 2009, at 5:13 AM, Charlie Griefer wrote: >> >> Pretty sure you need single quotes around bar. >> >> alert($("input[name='bar']").val()); >> >> >> No. The single quotes are unnecessary. >> >> On Thu, Sep 17, 2009 at 1:27 AM, pritisolanki >> wrote: >> >>> >>> Thanks Ralph. >>> >>> I tried following >>> >>> alert($("input[name=bar]").val()); >>> >>> and rather then showing it's value it alert undefined ??? why? >>> >> >> Where are you including your script tag? If it's in the , are you >> wrapping your alert() in $(document).ready? Are you sure you have an input >> with name="bar"? >> >> Try this: >> >> $(document).ready(function() { >> alert( $("input[name=bar]").val() ); >> }); >> >> >> --Karl >> >> >> Karl Swedberg >> www.englishrules.com >> www.learningjquery.com >> >> >> > > > -- > I have failed as much as I have succeeded. But I love my life. I love my > wife. And I wish you my kind of success. > > > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Simple CSS selector Question
Hi Karl: Hate to hijack the thread, but hopefully it's somewhat relevant to the original post. When I suggested the single quotes around the value 'bar', I was going off of what I saw in the docs at http://docs.jquery.com/Selectors/attributeEquals#attributevalue And the code sample: $("input[name='newsletter']").next().text(" is newsletter"); I still consider myself relatively new to jQuery, so could you clarify about quoting the attribute value? Is it similar to terminating a line with a semi-colon (e.g. optional in JS)? Or is it literal text vs variable value (assuming -bar- here is a variable)? Thanks! Charlie On Thu, Sep 17, 2009 at 9:06 AM, Karl Swedberg wrote: > > On Sep 17, 2009, at 5:13 AM, Charlie Griefer wrote: > > Pretty sure you need single quotes around bar. > > alert($("input[name='bar']").val()); > > > No. The single quotes are unnecessary. > > On Thu, Sep 17, 2009 at 1:27 AM, pritisolanki > wrote: > >> >> Thanks Ralph. >> >> I tried following >> >> alert($("input[name=bar]").val()); >> >> and rather then showing it's value it alert undefined ??? why? >> > > Where are you including your script tag? If it's in the , are you > wrapping your alert() in $(document).ready? Are you sure you have an input > with name="bar"? > > Try this: > > $(document).ready(function() { > alert( $("input[name=bar]").val() ); > }); > > > --Karl > > > Karl Swedberg > www.englishrules.com > www.learningjquery.com > > > -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Simple CSS selector Question
Pretty sure you need single quotes around bar. alert($("input[name='bar']").val()); On Thu, Sep 17, 2009 at 1:27 AM, pritisolanki wrote: > > Thanks Ralph. > > I tried following > > alert($("input[name=bar]").val()); > > and rather then showing it's value it alert undefined ??? why? > > I am sorry if this is very basic question. > > On Sep 16, 4:11 pm, Ralph Whitbeck wrote: > > Take out the @ in your attribute selectors. The @ was depricated in > jQuery > > 1.2 and taken out in 1.3. So your new selectors will look like... > > > > 1. $("input[name=bar]") > > > > 2. $("p[class]") > > > > documentationhttp:// > docs.jquery.com/Selectors/attributeHas#attributehttp://docs.jquery.com/Selectors/attributeEquals#attributevalue > > > > Ralph > > > > On Wed, Sep 16, 2009 at 2:36 AM, pritisolanki > wrote: > > > > > Hi, > > > > > I am a beginner in Jquery who simply set up the configs and start > > > exploring.please help me in following. I have starter kit html page. > > > > > > > >Form 2 > > > > > > > > > > > > > > > > > Okie this is hiding example > > > > > > > > In script tag following things do not take effects > > > 1. alert($("inp...@name=bar]").val()); - it suppose to alert the value > > > of this input. > > > 2. $("p...@class]").hide(); - My understanding is inner tag should > > > get hide -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Error when update jquery from 1.2.4 to 1.3.2
In 1.3 the @ was deprecated. see http://docs.jquery.com/Release:jQuery_1.3 under "Changes" now you just want $("form[name='adminform']").submit(); On Wed, Sep 16, 2009 at 9:03 PM, tongkienphi wrote: > > Hi every body. > > In my porject use jquery version 1.2.4, but this version can not run > Calendar app because in this app have use version 1.3.2 .. When i > updated to 1.3.2 script Calendar work well but in my project have > errror somewhere .. > > ex: on line 1642 have error from .. throw "Syntax error, unrecognized > expression: " + expr; > In the versioin 1.2.4 i use this code before to submit form > > $("fo...@name=adminform]").submit(); > > but in the version 1.3.2 this code not work. -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: selectors, events, and scripted elements not working
Have a look at live() http://docs.jquery.com/Events/live "Binds a handler to an event (like click) for all current - and future - matched element." Basically, when you add elements to the DOM dynamically after page load, jQuery won't recognize those elements unless the live() method is used. On Tue, Sep 15, 2009 at 4:20 PM, rob wrote: > > Hello, > > I am having some problems with selectors and events. I have a row of > thumbnails all part of the "thumbnails" class. I'm trying to run some > code when a thumbnail is clicked, but something weird is happening. > > When i use this selector/event: > " $(".thumbnails").click(function(){ // run some code }); > > nothing happens. > > I've tested this: > " $("img").click(function(){ // run some code }); > > And the code does run on what seems like all that are set in the > HTML doc, but not the elements that are created from JQuery > script. > > Can anyone help to explain this? What am I doing wrong here? > > For reference: > > The jquery script creating elements is: > > $(function(){ > var image = new Image(); > > $(img).attr('src', path) > $(img).attr('class', "thumbnails"); > > $('#thumbnailwrapper').append(img); > -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: $(this).css({"color" : "red"})
All 3 of the samples I pasted above (the pastebin links) work in FF3.5 (on OS X) On Sat, Sep 12, 2009 at 5:07 PM, Matthew Rolph wrote: > it's still not working right so i'm getting safari and seeing if that works > out > > > On Sat, Sep 12, 2009 at 1:10 PM, jhm wrote: > >> >> The code on that page doesn't match the code in your file. Yours is >> missing the curly brackets: >> >>$("p.blue").css("color" : "red"); >> >> should be >> >>$("p.blue").css({"color" : "red"}); >> >> Any syntax error like that will stop the script dead. >> >> >> On Sep 12, 9:58 am, Matthew Rolph wrote: >> > http://testingspot.hostcell.net/sandbox/tests/css.jquery.test.html >> > it somehow doesn't work at all not even the css >> > does it matter where the style and scripts are in the of the document >> > >> > On 9/12/09, Mike Alsup wrote: >> > >> > >> > >> > >> see that code in the subj.? i'm using FF 3.5, and no matter what i >> > >> do, .css won't work!! any help? >> > >> > > Maybe "this" isn't what you think it is. Can you post some code or a >> > > link? >> > > -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: $(this).css({"color" : "red"})
as does this: http://pastebin.com/m58a02ab3 On Sat, Sep 12, 2009 at 10:05 AM, Charlie Griefer wrote: > These both work for me: > > http://pastebin.com/m3701f681 > http://pastebin.com/m62f8b24b > > > > On Sat, Sep 12, 2009 at 9:58 AM, Matthew Rolph wrote: > >> >> http://testingspot.hostcell.net/sandbox/tests/css.jquery.test.html >> it somehow doesn't work at all not even the css >> does it matter where the style and scripts are in the of the document >> >> On 9/12/09, Mike Alsup wrote: >> > >> >> see that code in the subj.? i'm using FF 3.5, and no matter what i >> >> do, .css won't work!! any help? >> > >> > Maybe "this" isn't what you think it is. Can you post some code or a >> > link? >> > > > > -- > I have failed as much as I have succeeded. But I love my life. I love my > wife. And I wish you my kind of success. > -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: $(this).css({"color" : "red"})
These both work for me: http://pastebin.com/m3701f681 http://pastebin.com/m62f8b24b On Sat, Sep 12, 2009 at 9:58 AM, Matthew Rolph wrote: > > http://testingspot.hostcell.net/sandbox/tests/css.jquery.test.html > it somehow doesn't work at all not even the css > does it matter where the style and scripts are in the of the document > > On 9/12/09, Mike Alsup wrote: > > > >> see that code in the subj.? i'm using FF 3.5, and no matter what i > >> do, .css won't work!! any help? > > > > Maybe "this" isn't what you think it is. Can you post some code or a > > link? > -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: jquery offline Help document
On Sun, Sep 6, 2009 at 9:22 PM, vipin wrote: > > How can i get jquery API offline help document. > See http://docs.jquery.com/Alternative_Resources for some options. -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Clickable ?
I don't know that you can use a filter the way you're trying to (using the colon in #logo:a). Filters are more like tr:first (matches the first element), tr:odd (matches odd-numbered table rows.. good for zebra-striping)... See the sections about the various types of filters at http://docs.jquery.com/Selectors. As far as your issue... the 'a' in question is a child of the #logo element, so you'd want $('#logo > a').click(function() { }); http://docs.jquery.com/Selectors/child#parentchild On Fri, Sep 4, 2009 at 10:53 AM, lukas wrote: > > Thank you! It somehow does not work. > > Here is what I got: > $("#logo:a").click(function(){ >$.cookie('startCookie', 'default').load(' > http://www.mylink.com'); >}); > > And here is the html: > a> > > Does anybody have an idea? -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Clickable ?
Oooh good call. I had forgotten :) On Fri, Sep 4, 2009 at 10:20 AM, MorningZ wrote: > > and don't forget to add the css "cursor: pointer" to make the user's > mouse cursor look like a link > > > On Sep 4, 1:15 pm, Charlie Griefer wrote: > > does that div have an id attribute? if so, > > > > $('myDivID').click(function() { do stuff here }); > > > > On Fri, Sep 4, 2009 at 10:13 AM, lukas wrote: > > > > > I have a that only contains an image. > > > How would I create a jquery-click function that basically would > > > represent a normal tag for his ? > > > Thank you! > > > > -- > > I have failed as much as I have succeeded. But I love my life. I love my > > wife. And I wish you my kind of success. > -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Clickable ?
does that div have an id attribute? if so, $('myDivID').click(function() { do stuff here }); On Fri, Sep 4, 2009 at 10:13 AM, lukas wrote: > > I have a that only contains an image. > How would I create a jquery-click function that basically would > represent a normal tag for his ? > Thank you! -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Do I need to include whole JQuery file ?
On Thu, Sep 3, 2009 at 4:28 AM, Gaurang Mistry wrote: > > Hello, > I am new to jquery. > > I am using only hide and show functions. > > Do I need to include whole jquery file ? > Which part of file I need to remove ? > I think manipulating the core file in any way is a bad idea. I mean orders of magnitude bad. You're only using hide and show now. What if a week from now you want to toggle() something? What if you want to get or set an attribute value via attr()? What if you want to... well, you get the picture. The whole jquery file is relatively small. Especially if it's minified. You can also load it up via google. This way it'd already be cached in a user's browser if they've previously gone to a site that called the jQuery code from google. http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js "> But really... modifying the core file is the absolute last thing I'd suggest. -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: How can I manipulate all the radios in one div?
assuming the particular div has an id="myDiv" attribute... $('myDiv input:radio') http://docs.jquery.com/Selectors/descendant#ancestordescendant (the docs are your friend) You could also apply a specific class name to the ones you want to manipulate. But if you don't want to (or can't) manipulate the markup, the code above should work. On Wed, Sep 2, 2009 at 4:12 PM, gilberto.ramoso...@gmail.com < gilberto.ramoso...@gmail.com> wrote: > > How can I manipulate all the radios in a div? For example say I have 2 > div and both have a couple of radio buttons and everyone has different > names. Say I wanted to manipulate only the radios in one of the div's > how could achieve that? -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Help getting elements name.
$('input:radio').click(function() { alert(this.name); }); But... as radio buttons, wouldn't they all have the same name? In any event, 'this' (or the jQuery $(this)) will give you a hook into the element that triggered the click. On Wed, Sep 2, 2009 at 12:44 PM, gilberto.ramoso...@gmail.com < gilberto.ramoso...@gmail.com> wrote: > > Hello I have a bunch of radio button and I want a funtion tu run when > any of the radio button is clicked so I used $('input:radio').click > (function... what I want to do is to get the name attribute of the > clicked radio, how can i do this? -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.
[jQuery] Re: Dissect an ID
There may be a more elegant way, but until it comes along... you can .split() the string on the _ character. myArray = myString.split('_') which in your case would create an array with element 'thisisadiv' at position 0, and '1' at position 1. you could then reference it via myArray[1] On Sun, Aug 30, 2009 at 3:29 PM, Phil wrote: > > In jQuery how do I remove a certain part of an id... > > for example i have a div id='thisisadiv_1' > I want to remove the 'thisisadiv_' part > This is so I can add/subtract 1 to switch divs. > > Thanks in Advance. > Phil. -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.