-3

Instead of using :

$('input[id^="appName"]').each(function () {

            }  
        });

I would like to use a varibale for Attribute Starts With Selector

    var attrName = "appName";
    $('input[id^=attrName]').each(function () {

        }  
    });

The above syntax doesn't work. I checked the jQuery documentation and answers here without success.

Zeeshan
  • 11,851
  • 21
  • 73
  • 98

1 Answers1

3

try

 var attrName = "appName";
 $('input[id^=' + attrName + ']').each(function () {
      // do stuff here
 });

http://jsfiddle.net/swm53ran/156/

indubitablee
  • 8,136
  • 2
  • 25
  • 49
Balachandran
  • 9,567
  • 1
  • 16
  • 26