mercredi 6 juillet 2016

How to assign javascript function to an element attribute

I want to assign a javascript function to an HTML attribute. for eg:

 <li data-ng-repeat="job in jobList" class= foo(str) data-filter = "foo1(str)">

i want to do this because the class name and data attribute changes by job. finding the <li> element and changing is not possible as it is a list of elements.

i tried using

class=foo(str)
class = javascipt'foo(Str);'

not able to get it right.

Aucun commentaire:

Enregistrer un commentaire