Skip to main content

Bug Tracker

Side navigation

#7720 closed bug (invalid)

Opened December 07, 2010 01:19PM UTC

Closed December 07, 2010 01:45PM UTC

Uncaught Syntax error, unrecognized expression: # when using $('#' + var);

Reported by: bart@bartmax.com Owned by:
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.3
Keywords: Cc:
Blocked by: Blocking:
Description

var $this = $(this);

var id = $this.attr('for');

var val = $('#' + id).val();

this throws an Uncaught Syntax error, unrecognized expression: #

Attachments (0)
Change History (1)

Changed December 07, 2010 01:45PM UTC by rwaldron comment:1

resolution: → invalid
status: newclosed

This is not a jQuery bug. I'd suggest checking the value of id before using it in your selector.

http://jsfiddle.net/rwaldron/XYQXr/