Skip to main content

Bug Tracker

Side navigation

#8076 closed bug (invalid)

Opened January 27, 2011 03:28PM UTC

Closed January 27, 2011 05:14PM UTC

Last modified January 27, 2011 08:32PM UTC'blur') possible selector issue

Reported by: Owned by:
Priority: low Milestone:
Component: event Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

The following code trims all textboxes (including dynamic ones) on blur:

$(function() {
  // Auto-trim all textboxes on blur
  $("input:text,").not(":disabled").live("blur", function () {
    var textVal = $.trim($(this).val()); // trim the value

This code does not work without the extra comma in the selector "input:text,". I've tried it in IE8 and FF3.6. The selector "without comma" works when not using ".live()", but then it won't apply to dynamic textboxes...

Attachments (0)
Change History (3)

Changed January 27, 2011 04:09PM UTC by comment:1

The test code is here:

By the way, I discovered that when I removed the not(":disabled") part from the selectors, it also worked without the comma!

Changed January 27, 2011 05:14PM UTC by jitter comment:2

component: unfiledevent
priority: undecidedlow
resolution: → invalid
status: newclosed

Thanks for taking the time to contribute to the jQuery project by writing a bug report and providing a test case!

This isn't a bug. The live documentation states:

DOM traversal methods are not supported for finding elements to send to .live(). Rather, the .live() method should always be called directly after a selector, as in the example above.

This directly applies to your test case. You could do $("input:text:not(:disabled)").live(...) instead which should work

Changed January 27, 2011 08:32PM UTC by anonymous comment:3

Thank you jitter for the clear explanation. Sorry about the false alarm. When I read the documentation before I did not understand what DOM traversal methods were. I do now :) Thanks again.