英文:
How to pass a variable from one function to another function jquery
问题
$('input[name="choix_livraison"]').on('click', function() {
var livraison = $(this).attr('data-nom')
console.log("verification si variable passe",livraison)
});
$("#cb_Nom").keyup(function() {
console.log("verification si variable passe",livraison)
});
英文:
hello I would like my delivery variable created in the first function to be used in the second function
$('input[name="choix_livraison"]').on('click', function() {
var livraison = $(this).attr('data-nom')
console.log("verification si variable passe",livraison)
});
$("#cb_Nom").keyup(function() {
console.log("verification si variable passe",livraison)
});
答案1
得分: 2
var livraison;
$('input[name="choix_livraison"]').on('click', function() {
livraison = $(this).attr('data-nom');
console.log("verification if variable is passed", livraison);
});
$("#cb_Nom").keyup(function() {
console.log("verification if variable is passed", livraison);
});
英文:
var livrasion;
$('input[name="choix_livraison"]').on('click', function() {
livraison = $(this).attr('data-nom')
console.log("verification si variable passe",livraison)
});
$("#cb_Nom").keyup(function() {
console.log("verification si variable passe",livraison)
});
You can declare it as a global variable and since JQuery runs on the client side you don't have to worry about it being over written by other users.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论