Skip to content

Instantly share code, notes, and snippets.

@remzmike
Last active May 21, 2017 15:07
Show Gist options
  • Save remzmike/51b5035a68c470562b8c5ebcfc160b95 to your computer and use it in GitHub Desktop.
Save remzmike/51b5035a68c470562b8c5ebcfc160b95 to your computer and use it in GitHub Desktop.
vue jquery id confusion
// vue jquery id confusion
//
// in a template taking prop 'button_id'
// bound with: v-bind:id=button_id (or v-bind="{id:button_id}")
this.$props.button_id
// "#button1"
$(event.target).prop('id')
// "#button1"
$('#button1').prop('id')
// undefined
// WHAT? It can't find #button1.
document.getElementById('#button1');
// <button id=?"#button1" class=?"main_button">?hey?</button>?
// Found it, but what are the question marks about?
$(document.getElementById('#button1')).prop('id');
// "#button1"
// ...
$('#button1').prop('id');
// undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment