Bug Tracker

Opened 8 years ago

Closed 8 years ago

#7720 closed bug (invalid)

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

Reported by: bart@… 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: #

Change History (1)

comment:1 Changed 8 years ago by Rick Waldron

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/

Note: See TracTickets for help on using tickets.