jeudi 27 avril 2017

Passing varibel to jquery selector

I know there is tons of answer over this questions. And all answers are the same. I want to pass a variable to a selector. For example

var item = 'size_';
$("input[name="+item+"]").change(function () {
     console.log('got it');
});

Lets say

== M, So the var item ='size_M'

This far the code is doing ok. There is no problem in item variable. But in the selector instead of getting size_M it's getting the item string it self.enter image description here



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ozKFeT
via IFTTT

Aucun commentaire:

Enregistrer un commentaire