-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
  • 10,741
  • 18
  • 68
  • 94

1 Answers1

3

try

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

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

indubitablee
  • 7,968
  • 2
  • 24
  • 48
Balachandran
  • 9,427
  • 1
  • 14
  • 25