can you send the html too?
sorry .up() is prototype... should be .parent() instead.
On Aug 30, 1:20 pm, Josh Powell wrote:
> kali - here is a way to accomplish the same thing in less code, and
> lets you call the images anything you want instead of having to use
> numbers. This is untested so there ma
kali - here is a way to accomplish the same thing in less code, and
lets you call the images anything you want instead of having to use
numbers. This is untested so there may be some slight errors, but the
logic should be sound:
$(function() {
var imageArray = ['foo', 'bar', 'baz'];
Even simpler:
$('img.thumb').click(function () {
$(this).toggleClass('dim');
});
op using id's when you have an unknown or changing number of items
you are iterating through to do things. IDs should only be used for
unique items. When you have a list of similiar items doing the same
thing, give them all the same class or custom attribute and let jQuery
do the iterating for
Change the onclick event handler into a jQuery .live() event and
you'll be fine for sure.
On Aug 26, 1:57 pm, oleOhle wrote:
> OK, thanks everybody! I think I understand.
>
> Actually my second attempt could easily be rewritten to match exactly
> what jQuery does. It really boils down to the rem
.empty and .html looks in every node that it removes/replaces and
checks for and removes event bindings in order to prevent memory
leaks. If you know you do not have bound events, first use plain old
javascript to set element.innerHTML = ''; and then remove/replace the
element using .empty()/.htm
comparison against the selector every time
the mouse moves over an element on the page. This can cause some
dramatic slowdowns, especially if you are using multiple live events
of these types. It's often better to use regular events for
mouseover, mouseout, and mousemove.
Josh Powell
On Jul 5, 9:
That's okay, javascript doesn't have associative arrays, only arrays
with object properties.
On Jun 22, 2:45 pm, Ricardo wrote:
> before someone complains: that function won't handle arrays (only
> objects)
>
> On Jun 22, 6:39 pm, Ricardo wrote:
>
> > Usually you'll send out parameters in query
zend with eclipse has some plugins. I don't use them though, so I'm
not sure where to get them.
On Jun 12, 2:13 pm, Arun wrote:
> Hi,
> Has anyone ever tried using the zend ide with jquery? Any comments on
> this would be appreciated.
>
> Arun
I think you are looking to namespace the event.
$(selector).live('click.ns');
$(selector).die('click.ns');
The die() will only remove the click that occurs with that namespace
and leave other click events alone.
On Jun 2, 12:07 pm, Laker Netman wrote:
> On Jun 2, 1:59 pm, Laker Netman wrote:
It's generally a good idea to post example code so we can see what you
are doing. That said, this article I wrote will probably help you:
http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly
Josh Powell
On May 26, 8:29 pm, jonathan wrote:
> I am constructing
re trying to test
the method, then the method should be pulled out and tested
individually, if you are trying to test the pattern then you should
test the most efficient patterns for each method.
On May 22, 10:35 pm, RobG wrote:
> On May 23, 6:48 am, Josh Powell wrote:
> [...]
>
> &
One of the areas of the comparison where jQuery fares the worst is
"destroy." jQuery checks every element it is removing to see if there
are events bound to it and removes those events because they can cause
memory leaks. None of the other libraries do this. I do wish that
jQuery provided a met
What do you want to use the library for?
Selecting DOM Elements
DOM Manipulation
Simplifying Events
Simplifying Ajax
Mimicking classical inheritance
Extending native objects with 'missing' capabilities
Cool Widgets
>From what I can tell, these are the main areas of focus of all the
major javascr
The Definitive Guide is a great reference book, and a terrible book to
learn javascript from.
Javascript: The Good Parts is a must read to understand the
prototypical nature of javascript, learn about jslint, and understand
== vs ===
I can't speak to Learning Javascript
On May 19, 6:15 pm, d3a1
ment is finished loading, at that point the document.write() will
already have executed and thisStory.title won't exist yet.
Josh Powell
On May 19, 2:22 pm, illovich wrote:
> Hi, I'm working on a page where graphics/content get loaded via server
> side stuff and decided to try to use JSON t
r but there is lots of good stuff in there.
You can also start readign at: http://javascript.crockford.com/
Josh Powell
On May 18, 12:37 pm, alex wrote:
> Ah. I'm sure this sounds dunce-y because 'jQuery does it for me', but
> is a solid grounding in Javascript ne
If you aren't forced to use XML, look at trying JSON instead. It is a
MUCH friendlier format for passing information around.
On May 17, 11:09 pm, KrushRadio - Doc wrote:
> Paypal Transaction ID: 8PY233604R986225R :D
>
> Thanks for your help.
>
> Actually, there were 2 parts that I didn't get..
Try this:
http://www.learningjquery.com/category/levels/beginner?order=ascending
On May 5, 9:08 am, kiusau wrote:
> On May 5, 8:24 am, Rey Bango wrote:
>
> > Great advice Matt.
>
> But, no source!
>
> Roddy
your code.
Josh Powell
On Apr 26, 7:42 am, Sparky12 wrote:
> Problem is that I read
> thehttp://docs.jquery.com/Using_jQuery_with_Other_Libraries
> - and i use "jQuery" now ? So not sure why its occurring?
>
> P.S - About code - i dont even use my own code. I just use thi
It would be much easier to generate a json response instead of html
and use .getJSON and then the DOM insertion functions to generate the
html you need on the page.
On Apr 23, 1:41 am, Colonel wrote:
> This isn't entirely correct, and not quite what I had. For example I
> have a lots of divs in
what does ajax.php return?
at what stage is the error, beforesend, error, success, complete? Put
in a console.log and see if it is executed in each of the states.
Just a style suggest, but reverse your usage of quotes:
$('#searchresult').html(' ');
instead of
$('#searchresult').html(" ");
It sounds like John is saying that
e.preventDefault() will prevent the default event from occuring and
e.stopPropogation() will prevent the event from bubbling up and
return false will do both, so
If you only want to stop the default but allow propogation or vice
versa, then use the methods, oth
http://docs.jquery.com/Core/jQuery.noConflict
On Apr 20, 12:54 pm, amanj wrote:
> Hi All,
> i have a problem with web page, i have 2 js files for tow topic
> jquery-1.2.6.min.js
> mootools.v1.1.js
> those file are not compatable togeher, please if have any thing or any
> problem could you advic
Geoff - Selectors do make some difference, they always do, but the way
I've heard that .live() works is to add an event handler on the
document root and when events bubble up to it, doing some javascript
mojo to detect what element that event happened on and seeing if it
matches the selector. .li
Below is the call and where the code passed into the call would place
the content.
$('#aP').before();
$('#aP').prepend();
lorem ipsim dolor sit amet...
$('#aP').append();
$('#aP').after();
On Apr 18, 11:49 pm, MauiMan2 wrote:
> Does jQuery provide a way to append an element immediately before
Thanks all,
Josh
On Apr 16, 12:06 pm, Kean wrote:
> @Josh Powell
> - string concatenation is plenty fast 99% of the time and a lot more
> readable.
> Yes string concatenation is more readable and 99% faster for normal
> usage. But looping and concatenate a huge chunk in this pa
@all - So far, the only reasons I've heard not to add custom
attributes are 1) Dogma, 2) May cause quirks mode. In my mind, the
benefits gained by using custom attributes: less code, simplicity, and
clarity, far outweigh these two reasons not to do it.
@Jack K - Thanks for the links :). I will
> ...what is wrong with just having:-
> var todayEl = document.getElementById("today");
> todayEl.innerHTML = formatDate(new Date);
document.ElementById has a bug in ie6 and ie7 that will return an
element with a name attribute of the same value. Use $('#today')
instead.
todayEl.innerHTML = "so
@all - thank you for your comments. What I've learned is 1) custom
attributes are referred to as DOM Expandos, 2) they can cause IE to go
into strict mode, 3) Developers often override the class or id of an
element to store data instead of using a DOM Expando, and 4) There is
a bug in jQuery hav
I cannot use .data() as I do not have a node. Creating a node for
every td creates impossibly excessive append time. One one page I
shortened the time to append for 500 table rows from 29,000ms to
900ms. Good to know about the potential for triggering quirks mode
though, thanks.
Josh Powell
.bind enables you to pass variables into the callback function via the
e.data attribute in the event.
$(document).bind('click', {'foo': 'bar'}, function(e) {
console.log(e.data.foo);
});
Can't do that with the .click shortcut.
Josh Powell
On Apr 6, 9:53 a
27; > td).each(
function () {
alert($(this).text()); // to get just the text
alert($(this).html()); // to get the full html inside instead
}
);
Find more on selectors at:
http://docs.jquery.com/Selectors
and more on the .text() & .html() at:
http://docs.jquery.com/
instead of obj['name'] use obj.name They both work, but the first
makes it look like a hash when you are really using properties of an
object.
Cheers,
Josh Powell
While not what you were asking, remember that you can chain.
var name = $("#label");
var nameInfo = $("#nameInfo");
name.blur(validateName).keyup(validateName);
...
nameInfo.text("We want names with more than 3 letters!").addClass
("error");
Then:
$('#addPhoneExt').click(tb_remove);
sets an on
In this:
jQuery(document).ready(function($){
$("#example").autocomplete(options);
});
this:
function($) {
})
is overwriting the $ for prototype. It should be:
jQuery(document).ready(function(){
$("#example").autocomplete(options);
});
without passing t
You could also put the .click events inside a document.ready(). Then
they can click away, but no results until the event handler is set
after document.ready.
On Mar 20, 12:30 pm, James wrote:
> That's the default of how web browsers. You can work around it such as
> by setting the display of th
ns nothing
> > $(this).val() returns "on" no matter if you click on button Yes or
> > button No
> > I have been ckecking jquery doc the best I could and cannot find
> > answer to my question: how to I know if user clicked on button Yes or
> > button No
> >
read up on the .animate() jQuery effect, this might be what you are
looking for.
http://docs.jquery.com/Effects/animate
On Mar 15, 11:46 am, Tom Shafer wrote:
> I have articles in a group of divs
>
> width="11"
> height="211"/>
>
>
is a perfectly valid way to
code.
On Mar 14, 2:10 pm, donb wrote:
> Then I must be missing something:
>
> $("#placetoinsert").load("path/to/url");
>
> would do the same thing, with the tableHTML constructed on the server
> side.
>
> On Mar 14, 5:02 p
The problem is this:
$(".block a").mouseover(function(){
$(".block a").animate({
$('.block a') gets every instance of an a element with class block.
So when you do the .animate on it, you are animating every element.
Instead, you mean.
$(".block a").mouseover(function(){
$(this).
Because it puts it in the javascript and lets you easily manipulate it
with javascript. If you get html back from the server, it's more
difficult to manipulate.
$.getJson('path/to/url', function(data) {
var tableHTML = '';
$.each(data.aaData, function() {
tableHTML += '' + this
[name=row]
On Mar 14, 10:58 am, Alain Roger wrote:
> Hi,
>
> i have a table with checkboxes which allows user to select all row/records
> or none.
> they have all the same name : row
> i would like to know if there is an easy way to find them in my table ?
> i was thinking about something like
doc) that you can use
> > jQuery('.choix').click(function(e) {
> > $(this).parent().parent().hide();
> > and it will go 2 levels up instead of one as described in you solution
> > Thanks to great people like you Josh I am learning ( slowly)
> > Many thanks
&g
No, JSON is the correct route. If you are using ajax to retrieve
json, then you can pull the json into a javascript object
immediately. If you are using PHP to generate pages, then you can
print out the JSON object as a string directly into javascript and
create javascript objects that way. jQu
$("#msgUnits").text( ); will definitely not work. is not
the name of a javascript object.
On Mar 13, 9:46 pm, Swatchdog wrote:
> This does not work:
>
> $("#msgUnits").text( );
>
> nor does this...
>
> $("#msgUnits").text(' ');
>
> I guess is html only?
>
> Clues, anyone?
.. it will hide the related div with id="quest1" or
> quest 2...
> Any ideas
> Thanks for help
> Jean from France
>
> On 14 mar, 00:57, Josh Powell wrote:
>
> > What this is doing:
>
> > jQuery('.choix1').click(function(){
> > jQuery
What this is doing:
jQuery('.choix1').click(function(){
jQuery('#quest1').hide();
});
is looping through every element on the page with a class of 'choix1',
so you could either change all of the elements you want to loop though
classes to choix and then do
jQuery('.choix').click(function(){
Where does this error come from?
[cycle] terminating; zero elements found by selector
You can see it when the page loads on the firebug console, but it
doesn't give a file name or line number. it may be that since you
aren't getting any elements back, IE is messing up because you are
trying to
1
2
3
4
5
content
content
content
content
content
$('.numberPages').change(function() {
$('p.foo').hide().eq($(this).find(':selected').text()-1).show();
});
You can still use name, just change your selector to
$('[name=div1]')
Also, when writing out html in string, put them between single quotes
and the html in double quotes so you can do this:
var htmlText = 'Hola!!';
instead of
var htmlText = 'Hola!!';
Josh Pow
@7times9
I'm not sure what eq() stands for, come to think of it, but I always
read it in my heads as 'equals' as in the index equals 2.
> On Thu, Mar 12, 2009 at 10:04 AM, 7times9 <7tim...@googlemail.com> wrote:
>
> > ...what does eq as in .eq(2) stand for?
>
> > It helps me to read jQuery in my
@mkmanning
> An even more important performance gain can be had by
> not doing string concatenation (I put a caveat about this in the code
> comment's also), but build an array of your html and then join the
> array; it's siginficantly faster.
Funny that you mention this. In current browser vers
;).slice(3) + ]').val($
(this).val());
});
I personally find this kind of string munging difficult to read and
maintain. Could just be personal preference though. Good luck.
Josh Powell
On Mar 10, 10:39 pm, Eric Gun wrote:
> @mkmanning: Well done!! Your script works well. Thanks, and gre
6 of one... half dozen of another...
On Mar 7, 12:04 pm, brian wrote:
> On Sat, Mar 7, 2009 at 2:16 PM, Josh Powell wrote:
>
> > Why do you have the [] characters in the name of the elements? That
> > might screw up selectors.
>
> PHP, likely. But there's n
Why do you have the [] characters in the name of the elements? That
might screw up selectors.
Another options is to give the dealAmount inputs a new attribute with
a value of an incrementing numbers, foo="0" say. As long as the post
amounts are in the same order you could:
$('[name=dealAmount'
Long answer:
Check out the section on Traversing in the jquery documentation on the
site. Lots of good examples and documentation on there.
Short answer:
console.log($(element).children()));
On Mar 7, 1:33 am, Alain Roger wrote:
> Hi,
>
> i need to debug jQuery code and i would like to know
Did you mean to:
instead of
On Mar 5, 3:37 pm, dawnerd wrote:
> Can you please post the html you were using?
>
> On Mar 5, 2:32 pm, Dr G wrote:
>
> > Hello,
>
> > I've downloaded both the compressed & uncompressed versions and tried
> > both the initial example from the jquery site (http:
Simple answer:
DOM nodes are created by just writing the html in side of the jQuery
$('#divName').append('');
is equivalent to
divResult = document.getElementById("divName");
table = document.createElement("table");
tr = document.createElement("tr");
td = document.createElement("td");
tr.appen
Hey guys,
This thread inspired me to write a blog article
http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly
I did some testing of the += and array.join methods of long string
concatenation. Interesting stuff!
It turns out that += and array.join are browser dependent
Using console.log and firebug will show you what everything is.
console.log(data);
$.each(data.records, function(i,item){
console.log(i);
console.log(item);
console.log(this);
});
On Mar 2, 1:54 am, Alain Roger wrote:
> On Mon, Mar 2, 2009 at 10:52 AM, Matt Quackenbush wrote:
>
>
>
> >
It's just a javascript file, put it wherever you put your javascript
files.
On Mar 1, 12:20 pm, Warfang wrote:
> What code do I need to put in my HTML header? I have already
> downloaded the JQuery code from JQuery's homepage to my computer, but
> where exactly do I put that? I'm using Webs.com
oh, very nice. I wasn't aware of toggleClass.
On Feb 27, 6:51 pm, Karl Swedberg wrote:
> Hi Zac,
>
> You just need to add one line -- $(this).toggleClass('yourClass'); --
> where "yourClass" is the class you want to toggle on and off.
>
> You should also add return false after that line so th
hmmm, tough one, it was fun.
$(function() {
var color = '';
$('#everyother tr').each(function() {
if( $(this).hasClass('className') ) {
color = 'red';
} else if (color === 'red') {
$(this).css({'background-color': 'red'});
color = '';
Without really understanding what your fadeToggle plugin is doing,
this will toggle adding and removing a class:
$(function() {
$('a.aboutlink').toggle(
function () {
$(this).addClass('aboutBox');
http://groups.google.com/group/jquery-dev/browse_thread/thread/3efd1066b535234f
On Feb 27, 3:19 pm, ml1 wrote:
> Hi folks:
>
> We use jquery extensively in an application that suddenly needs to
> make use of an online ecommerce system that also happens to use
> jquery.
>
> This is causing thin
67 matches
Mail list logo