0

Hi guys ive got a button with jquery like this :

<html>
<button id = "index.php">
</button>

</html>

<script>
$('#index.php');').click(function(){
//stuff

});
</script>

however it seems that the id with a "." isnt accepted by jquery - is there a way to make it work?

James
  • 659
  • 1
  • 5
  • 25

1 Answers1

1

Try escaping the .

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<button id = "index.php">
</button>
<script>
$('#index\\.php').click(function(){
console.log('stuff');
});
</script>
Scaramouche
  • 3,188
  • 2
  • 20
  • 46