javascript - Find all onclick attributes and append a value to them -


I am trying to find all the elements with a onclick attribute and toggle the " () "Add" var original attribute = $ ('[onclick]'). Attr ('onclick'); $ ('[Onclick]') Attr ('onclick', original attribute + 'toggle ()');

Something is clearly wrong, but what?

$ ('[onclick]'). Attr ('onclick'); First will return a value for the mailing element.

All you need to do is try this for each element:

  $ ('[onclick]'). Each (function () {var $ this = $ (this); var originalAttribute = $ this.attr ('onclick'); $ This.attr ('onclick', original attribute + 'toggle');}) ;   



Comments

Popular posts from this blog

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -