-3

In this case :

the HTML content(Note: the id contains a .):

<input id="register.address1" name="address1" class="text" value="" type="text">

the jQuery content:

$("#register.address1").css('display','none');

I am unable to make changes to this register.address1 because it contains a .. I concluded it after replacing the . with a - gave me desired result.

But as I am not allowed to change the register.address1 because the framework in which I am working does not allow me to do so. So what is other work around for this problem?

KNU
  • 2,560
  • 5
  • 26
  • 39
  • 1
    possible duplicate of http://stackoverflow.com/questions/605630/how-to-select-html-nodes-by-id-with-jquery-when-the-id-contains-a-dot or http://stackoverflow.com/questions/350292/how-do-i-get-jquery-to-select-elements-with-a-period-in-their-id – SubjectCurio Mar 09 '15 at 12:57
  • 1
    Similary question and answer here http://stackoverflow.com/a/3913170/1932746 – Keith V Mar 09 '15 at 12:57
  • I think writing this question was more effort than searching for an answer – empiric Mar 09 '15 at 13:00
  • 1
    You can use `$("div[id='register.address1']")` – BeNdErR Mar 09 '15 at 13:01

1 Answers1

1

From jquery selectors docs escape your id like,

$("#register\\.address1").css('display','none');

And to hide any element you can use hide() like,

$("#register\\.address1").hide();

$('#register\\.address1').hide();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="register.address1" name="address1" class="text" value="" type="text">
Rohan Kumar
  • 40,431
  • 11
  • 76
  • 106