Jimbo
Jimbo

Reputation: 22964

jQuery selector for an HTML element whose id contains a point (.)

The element:

<input type='text' id='Customer.name' value='' />

The invalid jQuery selector:

$('#Customer.name')

Does anyone know what the selector should be for this element?

Upvotes: 17

Views: 12028

Answers (3)

Svetlin Panayotov
Svetlin Panayotov

Reputation: 620

From the jquery documentation:

$("#Customer\\.name")

jQuery FAQ

Upvotes: 5

Fr&#233;d&#233;ric Hamidi
Fr&#233;d&#233;ric Hamidi

Reputation: 262939

You can escape the period character with two backslashes:

$('#Customer\\.name')

Upvotes: 19

SeanCannon
SeanCannon

Reputation: 77966

$('input[id="Customer.name"]')

Example: http://jsfiddle.net/AlienWebguy/HFpEE/

Upvotes: 19

Related Questions