-
-
Save remzmike/51b5035a68c470562b8c5ebcfc160b95 to your computer and use it in GitHub Desktop.
vue jquery id confusion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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