0

I have observed that

$("#bank1.bankName").hide();

does not work while

$("test").hide() 

works

What is the reason for that ? What can be a possible work around

Edited to include markup

<td id = "bank1.bankName">
 <form:input path="bankDetails[0].bankName" size = "12"/>
 </td>

I am using Spring MVC

Abhishek Singh
  • 10,243
  • 22
  • 74
  • 108
  • think of id's and names like using variable names in a programming language. Try to stick with alpha, numeric, and underscore – Boundless Sep 30 '13 at 11:57

1 Answers1

6

The problem is because . is used to signify a class selector. Your current code is making jQuery search for an element with both the id bank1 and the class bankName.

To avoid this, you need to escape the . character with \\:

$("#bank1\\.bankName").hide();

Example fiddle

The best course of action is to not use the . character in id attributes at all. Whilst it is valid in the HTML5 specification, it leads to confusing cases such as this.

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339